Reputation: 22882
I'm trying to update to Guzzle 6 and in the changelog you have this:
Static functions in GuzzleHttp\Utils have been moved to namespaced functions under the GuzzleHttp namespace. This requires either a Composer based autoloader or you to include functions.php.
Now I have tried different ways of autoloading the functions but I'm getting different errors. What is the proper way of autoloading the functions on composer.json
I have added this to my composer.json:
"autoload": {
"files": ["vendor/guzzlehttp/guzzle/src/functions.php"]
}
Then after that I get an error:
PHP Fatal error: Cannot redeclare GuzzleHttp\uri_template() (previously declared in /home/fabio/flubit/dm/vendor/guzzlehttp/guzzle/src/functions.php:18) in /home/fabio/flubit/dm/vendor/guzzlehttp/guzzle/src/functions.php on line 32
So obviously I'm trying to load something that's already being loaded.
So I removed the autoload from composer and then try to use the json_decode()
built in function on Guzzle doing this \GuzzleHttp\json_decode()
I get this:
PHP Fatal error: Call to undefined function GuzzleHttp\json_decode()
Upvotes: 1
Views: 1710
Reputation: 2047
The Guzzle does provide the 'json' Request Option which can simplify the creation of sending json encoded requests. It will automatically encode using PHP's json_encode()
function and then set the appropriate content type header.
Upvotes: 0