{"id":22018335,"url":"https://github.com/biohzrdmx/curly-php","last_synced_at":"2026-04-12T21:49:13.579Z","repository":{"id":62494387,"uuid":"112780621","full_name":"biohzrdmx/curly-php","owner":"biohzrdmx","description":"Easy to use, general purpose CuRL wrapper","archived":false,"fork":false,"pushed_at":"2022-03-18T20:08:35.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-16T01:35:00.368Z","etag":null,"topics":["curl","https","php","proxy"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/biohzrdmx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-01T19:51:36.000Z","updated_at":"2021-12-02T17:58:21.000Z","dependencies_parsed_at":"2022-11-02T11:31:23.578Z","dependency_job_id":null,"html_url":"https://github.com/biohzrdmx/curly-php","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/biohzrdmx/curly-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohzrdmx%2Fcurly-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohzrdmx%2Fcurly-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohzrdmx%2Fcurly-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohzrdmx%2Fcurly-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/biohzrdmx","download_url":"https://codeload.github.com/biohzrdmx/curly-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biohzrdmx%2Fcurly-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31731413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T13:21:33.774Z","status":"ssl_error","status_checked_at":"2026-04-12T13:21:29.265Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curl","https","php","proxy"],"created_at":"2024-11-30T05:11:53.265Z","updated_at":"2026-04-12T21:49:13.559Z","avatar_url":"https://github.com/biohzrdmx.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"curly-php\n=========\n\nEasy to use, general purpose CuRL wrapper\n\n### Basic usage\n\nFirst require `biohzrdmx/curly-php` with Composer.\n\nNow get an instance of `Curly`, prepare your request and execute it:\n\n```php\nuse Curly\\Curly;\n\n$curly = Curly::newInstance()\n  -\u003esetMethod('GET')\n  -\u003esetURL('https://api.icndb.com/jokes/random')\n  -\u003esetParams([ 'limitTo' =\u003e 'nerdy' ])\n  -\u003eexecute();\n```\n\nOnce executed you'll need to call the `getResponse` method to retrieve the `Response` object and use the data for whathever you like:\n\n```php\n$response = $curly-\u003egetResponse();\nif ($response \u0026\u0026 $response-\u003egetStatus() == 200) {\n  $body = $response-\u003egetBody();\n  if ($body-\u003etype == 'success') {\n    echo $body-\u003evalue-\u003ejoke;\n  }\n} else {\n  echo 'API error: ' . $curly-\u003egetError();\n}\n```\n\nIt's important to note that `getBody` will parse `JSON` and `XML` payloads if the response has a valid `Content-Type` header, but you may disable that by passing `true` as the first parameter to get a `raw` response body;\n\nAlso if the request fails you may call `getError` or `getInfo` to find the cause of the failure.\n\nThe `Response` object can also retrieve the value of a single header with the `getHeader` method or all the response headers via the `getHeaders` one.\n\nAs this internally uses the `curl` extension, it supports `HTTPS` out of the box if you have a properly configured server, but you may specify the location of you CA bundle by passing it as the first parameter in the `newInstance` call:\n\n```php\n$cainfo = '/absolute/path/to/cacert.pem';\n$curly = Curly::newInstance($cainfo);\n```\n\nJust grab a copy of `cacert.pem` [from here](https://curl.haxx.se/docs/caextract.html) and pass its absolute path. Curly will automatically honor your `php.ini` if its properly set there.\n\n#### Downloading files\n\nStarting from version 2.2 it's possible to stream file downloads directly to a file handle, to do so you will need to pass a resource before executing the request:\n\n```php\n$resource = fopen('/absolute/path/to/file.zip', 'wb');\nif ($resource) {\n  $curly = Curly::newInstance()\n    -\u003esetMethod('GET')\n    -\u003esetResource($resource)\n    -\u003esetURL('https://my-web-app.com/assets/file.zip')\n    -\u003eexecute();\n  $response = $curly-\u003egetResponse();\n  fclose($resource);\n}\n```\n\nIn this case the file data is written directly to the resource, so `$response-\u003egetBody()` will return an empty string, but you can check the status with `$response-\u003egetStatus()` and get the corresponding headers with `$response-\u003egetHeader()` and `$response-\u003egetHeaders()`.\n\nRemember to always close the file with `fclose`;\n\n#### Uploading files\n\nAlso, there's support for file uploads with the `CURLFile` class,\n\n```php\nuse CURLFile;\n\n$avatar = new CURLFile('/absolute/path/to/avatar.png');\n$curly = Curly::newInstance()\n  -\u003esetMethod('POST')\n  -\u003esetURL('https://my-web-app.com/api/users/profile')\n  -\u003esetFields( ['email' =\u003e 'foo@bar.baz', 'avatar' =\u003e $avatar] )\n  -\u003eexecute();\n```\n\nJust add your files like any other field and set the request method to `POST`, the class adjust everything automatically.\n\n### Licensing\n\nThis software is released under the MIT license.\n\nCopyright © 2022 biohzrdmx\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n### Credits\n\n**Lead coder:** biohzrdmx [github.com/biohzrdmx](http://github.com/biohzrdmx)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiohzrdmx%2Fcurly-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiohzrdmx%2Fcurly-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiohzrdmx%2Fcurly-php/lists"}