{"id":41630953,"url":"https://github.com/rakit/curl","last_synced_at":"2026-01-24T14:34:23.904Z","repository":{"id":62532944,"uuid":"49657611","full_name":"rakit/curl","owner":"rakit","description":"PHP Simple cURL Wrapper","archived":false,"fork":false,"pushed_at":"2016-01-24T11:56:22.000Z","size":14,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-05T05:49:42.760Z","etag":null,"topics":[],"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/rakit.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":"2016-01-14T15:57:21.000Z","updated_at":"2024-04-02T14:48:01.000Z","dependencies_parsed_at":"2022-11-02T15:02:40.203Z","dependency_job_id":null,"html_url":"https://github.com/rakit/curl","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rakit/curl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakit%2Fcurl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakit%2Fcurl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakit%2Fcurl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakit%2Fcurl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rakit","download_url":"https://codeload.github.com/rakit/curl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakit%2Fcurl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28729794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T10:24:43.181Z","status":"ssl_error","status_checked_at":"2026-01-24T10:24:36.112Z","response_time":89,"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":[],"created_at":"2026-01-24T14:34:23.391Z","updated_at":"2026-01-24T14:34:23.894Z","avatar_url":"https://github.com/rakit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"rakit-curl\n==========\n\nJust another PHP cURL wrapper\n\n## Installation\nAs you can see, this library contain `composer.json` file. But at this time, i have not post this library on packagist. So if you want to use it via composer, you can manually add this repository in your `composer.json` file.\n\nSo, your `composer.json` file should look like this:\n\n```json\n{\n    \"require\": {\n        \"rakit/curl\": \"dev-master\"\n    },\n    \"repositories\": [\n        {\n            \"url\": \"https://github.com/emsifa/rakit-curl\",\n            \"type\": \"vcs\"\n        }\n    ]\n}\n```\nThen you can run `composer install` or `composer update`.\n\nOptionally you can download/clone this library and load it into your project.\n\n\n## Examples\n\n#### Example Get Request\n```php\nuse Rakit\\Curl\\Curl;\n\n$request = new Curl('http://wikipedia.com');\n$response = $request-\u003eget();\n\n// then, you can do something with response object\nif(! $response-\u003eerror()) {\n\n  // getting response file content\n  $html = $response-\u003egetBody();\n  \n  // simply get response content type\n  $content_type = $response-\u003egetContentType(); \n  \n  // get content type via curl info\n  $content_type = $response-\u003egetInfo('content_type'); \n  \n  // getting response cookies\n  $cookie = $response-\u003egetCookie();\n  \n  // simply get response header item\n  $http_version = $response-\u003egetHeader('http_version');\n  \n  // get all header items\n  $all_headers = $response-\u003egetHeaders();\n\n} else {\n\n  $error_code = $response-\u003egetErrno();\n  $error_message = $response-\u003egetErrorMessage();\n\n}\n```\n\n#### Using Request Parameter\n```php\nuse Rakit\\Curl\\Curl;\n\n$request = new Curl('http://targetsite.com/products');\n$request-\u003eparam('page', 2);\n$request-\u003eparam('category', 'software'); \n$response = $request-\u003eget();\n\n// do something with Response object\n\n```\n\n**or**\n\n```php\nuse Rakit\\Curl\\Curl;\n\n$params = array(\n  'page' =\u003e 2,\n  'category' =\u003e 'software'\n);\n\n$request = new Curl('http://targetsite.com/products');\n$response = $request-\u003eget($params);\n\n// do something with Response object\n\n```\n\n#### Example Post Request\n```php\nuse Rakit\\Curl\\Curl;\n\n$request = new Curl('http://targetsite.com/register');\n$request-\u003eparam('name', 'John Doe');\n$request-\u003eparam('email', 'johndoe@mail.com');\n$request-\u003eparam('password', '12345');\n$response = $request-\u003epost();\n\n// do something with Response object\n\n```\n\n#### Upload file? use addFile method\n\n```php\nuse Rakit\\Curl\\Curl;\n\n$request = new Curl('http://targetsite.com/register');\n$request-\u003eparam('name', 'John Doe');\n$request-\u003eparam('email', 'johndoe@mail.com');\n$request-\u003eparam('password', '12345');\n\n$request-\u003eaddFile('avatar', 'path/to/avatar.png');\n\n$response = $request-\u003epost();\n\n// do something with Response object\n```\n\n#### Send a cookie\n```php\nuse Rakit\\Curl\\Curl;\n\n$request = new Curl('http://targetsite.com/products');\n$request-\u003ecookie('key', 'value');\n$response = $request-\u003eget();\n\n// do something with Response object\n\n```\n\n#### Auto Redirect\nAuto redirect allow cURL to auto redirect while response is redirection (status: 3xx). \n\nExample:\n```php\nuse Rakit\\Curl\\Curl;\n\n$request = new Curl('http://targetsite.com/admin/product/delete/1');\n$request-\u003eautoRedirect(5); // 5 is maximum redirection\n\n$response = $request-\u003eget();\n\n// what if 6th request is also redirection? it's good to check\nif($response-\u003eisRedirect()) {\n    throw new \\Exception(\"Too many redirection\");\n}\n\n// do something with response\n```\n\n#### Storing Session\nIt is easy way to store session automatically with CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE. It is useful when you want to grab something that require session cookies to login or anything else. For use this, you must have directory that have access to write file for storing session.\n\nFor example you want grab redirected page after login:\n```php\nuse Rakit\\Curl\\Curl;\n\n$session_file = \"path/to/store/sitetarget.session\";\n\n$request = new Curl(\"http://sitetarget.com/login\");\n$request-\u003eautoRedirect(5);\n$request-\u003estoreSession($session_file);\n\n$response = $request-\u003epost(array(\n    'username' =\u003e 'my_username',\n    'password' =\u003e 'my_password'\n));\n\n// do something with response object\n```\n\n#### Create Simple Request\n\nWith simple request, you dont't need to create new Curl request object. \nBut you can't send a cookie, modify request headers, or even curl options.\n\n```php\nuse Rakit\\Curl\\Curl;\n\n// simple GET\n$response = Curl::doGet('http://targetsite.com', array('page' =\u003e 2));\n\n// simple POST \n$response = Curl::doPost('http://targetsite.com/product/delete', array('id' =\u003e 5));\n```\n\n## Response Object\nIn examples above, i always told you to do something with response object, but what it is? what you can do with response object?\n\nResponse object is object that returned from your cURL request. Response object contain result data from HTTP response such as response headers, cookies, body, etc.\n\nHere is that you can do with response object:\n\n#### isNotFound()\nShortcut for check response status code is 404 or not.\n```php\n$response = Curl::doGet(\"http://sitetarget.com/blablabla\");\n\nif($response-\u003eisNotFound()) {\n   // 404 page not found\n}\n```\n\n#### isRedirect()\nReturn true if status code is 3xx.\n```php\n// redirecting example\n\n$response = Curl::doGet(\"http://sitetarget.com/redirect-me\");\n\nwhile($response-\u003eisRedirect()) {\n    $redirect_url = $response-\u003egetHeader(\"location\");\n    $response = Curl::doGet($redirect_url);\n}\n\n```\n\n#### getBody()\nGetting response body like html code, image content, etc.\n\n#### length()\nGetting response length (response body string + response header string).\n\n#### isHtml()\nReturn true if response content-type is text/html.\n\n#### error()\nReturn true if there is error in request\n\n#### getErrno()\nGetting error code, 0 = no error.\n\n#### getErrorMessage()\nGetting error message, empty if no error\n\n#### getHeader($key, $default = null)\nGetting header item\n```php\n$response = Curl::doGet(\"http://sitetarget.com\");\n\n$http_version = $response-\u003egetHeader(\"http_version\");\n$content_type = $response-\u003egetHeader(\"content-type\");\n// and many more\n```\n#### getHeaders()\nGetting all header items as array.\n\n#### getHeaderString()\nGet response headers as raw header string.\n\n#### getStatusCode()\nGetting response status code.\n\n#### getContentType()\nShortcut for getting response content-type.\n\n#### getInfo($key, $default = null)\nGetting info item like curl_getinfo()\n\n#### getAllInfo()\nGetting all info as array.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frakit%2Fcurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frakit%2Fcurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frakit%2Fcurl/lists"}