{"id":21538197,"url":"https://github.com/php-guard/curl","last_synced_at":"2026-04-09T20:40:14.055Z","repository":{"id":57039766,"uuid":"151472542","full_name":"php-guard/curl","owner":"php-guard","description":"PHP Curl wrapper. Alternative to \"https://github.com/php-curl-class/php-curl-class\" with CurlRequest and CurlResponse objects","archived":false,"fork":false,"pushed_at":"2019-04-27T15:49:13.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T07:45:06.047Z","etag":null,"topics":["composer","curl","curl-multi","http","json","packagist","php","php-curl","php-curl-library","php7","proxy"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-guard.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":"2018-10-03T19:58:13.000Z","updated_at":"2019-04-27T15:49:14.000Z","dependencies_parsed_at":"2022-08-24T00:51:20.551Z","dependency_job_id":null,"html_url":"https://github.com/php-guard/curl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-guard%2Fcurl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-guard%2Fcurl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-guard%2Fcurl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-guard%2Fcurl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-guard","download_url":"https://codeload.github.com/php-guard/curl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244110086,"owners_count":20399561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["composer","curl","curl-multi","http","json","packagist","php","php-curl","php-curl-library","php7","proxy"],"created_at":"2024-11-24T04:11:02.709Z","updated_at":"2026-04-09T20:40:09.014Z","avatar_url":"https://github.com/php-guard.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# curl\n\n[![Build Status](https://scrutinizer-ci.com/g/php-guard/curl/badges/build.png?b=master)](https://scrutinizer-ci.com/g/php-guard/curl/build-status/master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/php-guard/curl/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/php-guard/curl/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/php-guard/curl/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/php-guard/curl/?branch=master)\n[![GPL Licence](https://badges.frapsoft.com/os/gpl/gpl.png?v=103)](https://opensource.org/licenses/GPL-3.0/)\n\n\nThis library is an alternative to \"https://github.com/php-curl-class/php-curl-class\". \nEasy use with CurlRequest and CurlResponse objects.\n\n### Installation\n\nInstall via [Composer](https://getcomposer.org/)\n\n    $ composer require php-guard/curl\n    \n### Requirements\n\n -   php: ^7.1\n\n\n### Usage\n\n\n##### Quick Start\n\n    require __DIR__ . '/vendor/autoload.php';\n    \n    use \\PhpGuard\\Curl\\Curl;\n\tuse \\PhpGuard\\Curl\\CurlError;\n    \n    $this-\u003ecurl  =  new  Curl();\n    \t\n\ttry {\n\t\t// Execute a single request\n\t\t$response = $this-\u003ecurl-\u003eget('http://example.com'); // Return a CurlResponse\n\t\techo $response-\u003eraw();\n\n\t\t// Execute multiple requests\n\t\t$responses = $this-\u003ecurl-\u003emulti() // Create a MultiCurl object\n\t\t\t-\u003eget('http://example.com')   // Add a get request\n\t\t\t-\u003epost('http://example.com')  // Add a post request\n\t\t\t-\u003eexecute();                  // Return an array of CurlResponse\n\n\t\tforeach ($responses as $response) {\n\t\t\techo $response-\u003eraw();\n\t\t}\n\t} catch (CurlError $e) {\n\t\techo 'Error: ' . $curl-\u003egetCode(). ': ' . $curl-\u003egetMessage(). \"\\n\";\n\t}\n\n##### Available Methods\n\n**\\PhpGuard\\Curl\\Curl**\n\nHTTP methods\n\n    get(string $url, $query = null, array $headers = []): CurlResponse\n    post(string $url, $data = null, $query = null, array $headers = []): CurlResponse\n    put(string $url, $data = null, $query = null, array $headers = []): CurlResponse\n    patch(string $url, $data = null, $query = null, array $headers = []): CurlResponse\n    delete(string $url, $data = null, $query = null, array $headers = []): CurlResponse\n    \nRun a single request\n    \n    execute(CurlRequest  $request): CurlResponse\n\nPrepare multiple requests\n\n    multi(array  $options  = []): MultiCurl\n    \nEdit request and response processing (advanced usage)\n\n    getCurlRequestFactory(): CurlRequestFactory\n    getRequestModifierPipeline(): RequestModifierPipeline\n\n\n**\\PhpGuard\\Curl\\CurlRequest**\n\nYou can use Curl to execute requests or you can use \nthe CurlRequestFactory to return CurlRequest instances.\n\nProperties url, method and data have getters and setters.\n\nThe method `setHeaderContentType(string $contentType)` is a shortcut for \n \n    $curlRequest-\u003egetHeaders['Content-Type'] = $contentType\n \nOther methods\n\n    execute(bool $throwExceptionOnHttpError = false): CurlResponse\n    getCurlOptions(): CurlOptions\n    getHeaders(): Headers\n\n**\\PhpGuard\\Curl\\MultiCurl**\n\n    get(string $url, $query = null, array $headers = []): self\n    post(string $url, $data = null, $query = null, array $headers = []): self\n    put(string $url, $data = null, $query = null, array $headers = []): self\n    patch(string $url, $data = null, $query = null, array $headers = []): self\n    delete(string $url, $data = null, $query = null, array $headers = []): self\n    execute(): CurlResponse[]\n\n**\\PhpGuard\\Curl\\CurlResponse**\n\n    statusCode(): int\n    isError(): bool // True if status code \u003e= 300\n    headers(): Headers\n    raw() // Raw content of the response\n    json() // Array or false if not a json response\n    \n**\\PhpGuard\\Curl\\CurlRequestFactory**\n\nSet the base url for all requests\n\n     setBaseUrl(?string $baseUrl): self\n     \nSet the option curl CURLOPT_SSL_VERIFYPEER     \n     \n     setSslVerifyPeer(bool $value): self\n     \nCreate a CurlRequest\n\n     create(string $method, string $url, $data = null, $query = null, array $headers = []): CurlRequest\n     \nEdit other default curl options\n     \n     getDefaultCurlOptions(): CurlOptions\n     getDefaultHeaders(): Headers\n\n**\\PhpGuard\\Curl\\Collection\\CurlOptions**\n\nThis class implements `\\ArrayAccess`. It can therefore be used as an array.\n\n**\\PhpGuard\\Curl\\Collection\\Headers**\n\nThis class implements `\\ArrayAccess`. It can therefore be used as an array.\n\nIn addition, the keys are case insensitive.\n\n**\\PhpGuard\\Curl\\RequestModifierPipeline**\n\nAdd an object to modify CURL requests\n\n    pipe(RequestModifierInterface $requestModifier): self\n    \nBy default, FileRequestModifier and PlainTextRequestModifier are active.\nIf necessary, you can add an instance of ProxyRequestModifier\n\n* ProxyRequestModifier allows you to define curl options to use a proxy\n\n* FileRequestModifier is used to manage file paths starting with @ \nand passed as a parameter by transforming them into CurlFile \nand then modifying the HTTP Content-Type header.\n\n* PlainTextRequestModifier changes the HTTP Content-Type header \nto text/plain when a string is passed as a parameter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-guard%2Fcurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-guard%2Fcurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-guard%2Fcurl/lists"}