I posted earlier “How to use HttpSocket instead of cURL in CakePHP 2“. In that blogpost I showed how easy it is to refactor your API requests from cURL to HttpSocket. In CakePHP3, HttpSocket is now Cake\Network\Http\Client and has been completely re-written from the ground up. CakePHP3 made cURL completely unnecessary with the new Http Client. Here are some examples to get you up to speed:
Basic requests
|
|
HttpSocket Request with basic HTTP authentication
|
|
Send and receive JSON
Let’s assume we send a JSON payload in the body request, and we receive JSON in the response
|
|
For more examples please look at the Http Client CakePHP book.
So again, what is your excuse to use cURL in your CakePHP3 project?