{"id":16409669,"url":"https://github.com/coderatio/curler","last_synced_at":"2025-03-23T06:30:59.918Z","repository":{"id":53078788,"uuid":"213643816","full_name":"coderatio/curler","owner":"coderatio","description":"An elegant PHP HTTP client for sending HTTP requests.","archived":false,"fork":false,"pushed_at":"2021-04-07T18:12:38.000Z","size":16,"stargazers_count":5,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T18:15:46.898Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/coderatio.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":"2019-10-08T13:03:57.000Z","updated_at":"2021-11-17T21:35:36.000Z","dependencies_parsed_at":"2022-08-21T08:20:37.007Z","dependency_job_id":null,"html_url":"https://github.com/coderatio/curler","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/coderatio%2Fcurler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderatio%2Fcurler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderatio%2Fcurler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderatio%2Fcurler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderatio","download_url":"https://codeload.github.com/coderatio/curler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245066496,"owners_count":20555402,"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":[],"created_at":"2024-10-11T06:20:47.937Z","updated_at":"2025-03-23T06:30:59.554Z","avatar_url":"https://github.com/coderatio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Curler\nAn elegant PHP HTTP client for sending HTTP requests.\n\n## Requirements\n* `php 7.1+`\n* `OpenSSL`\n* `cURL`\n\n## Installation\nThis library can easily be installed using composer. Run the command below:\n```shell script\ncomposer require coderatio/curler\n```\n\n___\n\n### `GET`\nBecause this is built with simplicity in mind from the beginning, below is how easy you can make a get request to another server.\n```php\n\nrequire 'vendor/autoload.php';\n\n$curler = new \\Coderatio\\Curler\\Curler();\n$curler-\u003eget('https://jsonplaceholder.typicode.com/todos');\n$response = $curler-\u003egetResponse();\n\n```\n### `POST`\n```php\n\n$data = [\n  'title' =\u003e 'Sample post',\n  'body' =\u003e 'This is a sample post',\n  'userId' =\u003e 1\n];\n\n$curler = new \\Coderatio\\Curler\\Curler();\n$request = $curler-\u003epost('https://jsonplaceholder.typicode.com/posts', $data);\n$response = $curler-\u003egetResponse();\n\n```\n### `POST FORM`\nSending form data via curler is as simple sending a `post` request. Just send an array of your form data and curler will take care of the rest. Take a look below:\n```php\n\n$data = [\n  'first_name' =\u003e 'John',\n  'last_name' =\u003e 'Doe',\n  'email' =\u003e 'johndoe@example.com'\n];\n\n$curler = new \\Coderatio\\Curler\\Curler();\n$request = $curler-\u003epostForm('https://example.com/store-user', $data);\n$response = $curler-\u003egetResponse();\n\n```\n\nBy default, the `$response` variable will hold a json object of the request. But, there are instances where you want the response in php object or array. You can get them as below:\n```php\n$response = $curler-\u003egetResponse()-\u003easObject();\n```\nOR\n```php\n$response = $curler-\u003egetResponse()-\u003easArray();\n```\n\n___\n\n## Other Request Methods\n1. PUT\n2. DELETE\n3. DOWNLOAD\n4. OPTIONS\n5. HEAD\n6. TRACE\n\nJust as you use the post, get, postForm e.t.c, you can also use the `put`, `delete`, `download`, `options`, `head`, and `trace` methods.\n\n___\n\n## Adding Custom Headers\nSometimes, you may need to send your request with custom headers. Curler, has full support for that and many more. Here is how it can be done.\n* ### Single Header\n```php\n\n$curler = new \\Coderatio\\Curler\\Curler();\n$curler-\u003eappendRequestHeader('Content-Type', 'application/json');\n$curler-\u003epost('https://jsonplaceholder.typicode.com/posts', $data);\n\n$response = $curler-\u003egetResponse();\n\n```\n\n* ### Multiple headers\n```php\n\n$curler = new \\Coderatio\\Curler\\Curler();\n$curler-\u003eappendRequestHeaders([\n    'Content-Type' =\u003e 'application/xml',\n    'x-access-token' =\u003e 'xxxxxxxxxx'\n]);\n\n$curler-\u003epost('https://jsonplaceholder.typicode.com/posts', $data);\n\n$response = $curler-\u003egetResponse();\n\n```\n\n___\n\n## Get Status Code\nSometimes, you may like to get the status code returned from a request. This can easily be done with curler as below:\n\n```php\n$curler-\u003estatuseCode;\n```\n\n___\n\n## Add cURL options\nSince this package is built with flexibility in mind, adding cURL options should be a breeze. Here is how you can add options:\n```php\n$curler-\u003eaddCurlOption('CURLOPT_PUT', true); // Single\n\n// OR\n\n$curler-\u003eaddCurlOptions([\n    'CURLOPT_PUT' =\u003e true,\n    'CURLOPT_POSTFIELDS' =\u003e []\n]);\n```\n\n## Contributors\nTo be a contributor, kindly fork the repo, add or fix bugs and send a pull request.\n\n## Contribution\nTo contribute to this project, kindly fork it and send a pull request or find me on \u003ca href=\"https://twitter.com/josiahoyahaya\"\u003eTwitter\u003c/a\u003e.\n\n## License\nThis project is licenced with the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderatio%2Fcurler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderatio%2Fcurler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderatio%2Fcurler/lists"}