New feature: provide your own HTTP client?
I was just wondering whether you might be open to a change from using curl directly, to allowing an HTTP client to be optionally provided to the package? The primary use-case for us is that we have an instrumented Guzzle/PSR-18 client, which if the package could use it, would give us helpful performance/tracing/debugging information!
Hey!
It is possible (albeit poorly documented) to pass your own Request instance to the library, e.g.
class MyRequest extends SpotifyWebAPI\Request
{
public function send()
{
// Do your thing
}
}
$request = new MyRequest();
$session = new SpotifyWebAPI\Session('CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI', $request);
$api = new SpotifyWebAPI\SpotifyWebAPI([], null, $request);
Let me just improve the docs a bit and add an additional helper or two and you'll be good to go!
Added some additional docs with some helper methods that could some in useful, Passing a Custom Request Instance. Hope this helps!
And just to provide some additional background. Given the age of this project, adding "proper" PSR-18 etc. support feels like a bit much and not worth the effort and possible breakage. With that said however, I have been chipping away at a "V2" with much more modern PHP features, full support for PSR-18 and friends, plus better typings but it's a slow process 😅