Re: [RFC] OOP API for cURL extension
| From: | Dik Takken | Date: | Thu, 15 Feb 2024 11:21:12 +0000 |
| Subject: | Re: [RFC] OOP API for cURL extension | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122384@lists.php.net to get a copy of this message | ||
On 14-02-2024 19:47, Sara Golemon wrote:
Good afternoon folks, I'd like to open discussion on adding OOP APIs to the cURL extension. https://wiki.php.net/rfc/curl-oop This has been a long standing bug-bear of mine, and I think its time has come. try { (new \CurlHandle)->setOpt(YOUR_VOTE, true)->exec(); } catch (\CurlHandleException $ex) { assert(false); // Why not?! } -SaraI love the idea of an OOP API. Personally I use Python's Requests library a lot, it could offer some inspiration. I would really like to simply write:
Curl::get('https://...', params: ['key' => 'value'])->json()
Curl::post(...)
...
Some more specific exceptions may be nice too, to easily differentiate between errors you might want to retry (network errors) and programming errors.
Regards,
Dik