Closed dnyg closed 6 years ago
Any news about this? Am I free to submit a pull request?
Adding default query string(s) changed in Guzzle 6
What exactly changed? How did you solve this before?
In versions prior to Guzzle 6 you could do
$client = new \GuzzleHttp\Client([
'base_uri' => 'https://example.com',
'query' => [
'key1' => 'value1',
'key2' => 'value2'
]
]);
This is no longer supported (see https://github.com/guzzle/guzzle/issues/1138)
I agree withQueryValues
makes it simpler. I'd gladly see a PR.
In versions prior to Guzzle 6 you could do
$client = new \GuzzleHttp\Client([ 'base_uri' => 'https://example.com', 'query' => [ 'key1' => 'value1', 'key2' => 'value2' ] ]);
This is no longer supported (see guzzle/guzzle#1138)
Since this is no longer supported, it seems unclear how to accomplish default query params. Not sure why it had to be more complicated than adding default options.
Adding default query string(s) changed in Guzzle 6 and now requires adding middleware like
When you need multiple default query strings you either have to do nested calls to
->withUri()
(which becomes unmanageable at already 2 parameters), or create a loop/recursive function to generate an Uri to pass intowithUri()
. Something likeNested
Loop
Feature Request:
withQueryValues()
It would be nice if the
GuzzleHttp\Psr7\Uri
class had awithQueryValues(UriInterface $uri, $valueArray)
function, so you could do something like