{"id":14985433,"url":"https://github.com/berliozframework/httpclient","last_synced_at":"2026-01-17T16:25:56.650Z","repository":{"id":46735770,"uuid":"99345819","full_name":"BerliozFramework/HttpClient","owner":"BerliozFramework","description":"Berlioz HTTP Client is a PHP library to request HTTP server with continuous navigation, including cookies, sessions...","archived":false,"fork":false,"pushed_at":"2025-06-17T13:42:40.000Z","size":689,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"2.x","last_synced_at":"2025-07-20T20:53:46.711Z","etag":null,"topics":["berlioz","composer","http-client","php","php-libraries","psr"],"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/BerliozFramework.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-08-04T13:33:18.000Z","updated_at":"2025-06-17T13:42:44.000Z","dependencies_parsed_at":"2024-03-22T13:28:26.534Z","dependency_job_id":"607607fe-df3a-45b4-b800-6c8322a0d6af","html_url":"https://github.com/BerliozFramework/HttpClient","commit_stats":{"total_commits":152,"total_committers":6,"mean_commits":"25.333333333333332","dds":0.03947368421052633,"last_synced_commit":"0df09f58e960d241008b2673d98f8e93d5de2324"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/BerliozFramework/HttpClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BerliozFramework%2FHttpClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BerliozFramework%2FHttpClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BerliozFramework%2FHttpClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BerliozFramework%2FHttpClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BerliozFramework","download_url":"https://codeload.github.com/BerliozFramework/HttpClient/tar.gz/refs/heads/2.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BerliozFramework%2FHttpClient/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266255249,"owners_count":23900100,"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":["berlioz","composer","http-client","php","php-libraries","psr"],"created_at":"2024-09-24T14:10:57.930Z","updated_at":"2026-01-17T16:25:56.627Z","avatar_url":"https://github.com/BerliozFramework.png","language":"PHP","readme":"# Berlioz HTTP Client\n\n[![Latest Version](https://img.shields.io/packagist/v/berlioz/http-client.svg?style=flat-square)](https://github.com/BerliozFramework/HttpClient/releases)\n[![Software license](https://img.shields.io/github/license/BerliozFramework/HttpClient.svg?style=flat-square)](https://github.com/BerliozFramework/HttpClient/blob/2.x/LICENSE)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/BerliozFramework/HttpClient/tests.yml?branch=2.x\u0026style=flat-square)](https://github.com/BerliozFramework/HttpClient/actions/workflows/tests.yml?query=branch%3A2.x)\n[![Quality Grade](https://img.shields.io/codacy/grade/3e9df26a706d4ac285e1a49176665751/2.x.svg?style=flat-square)](https://app.codacy.com/gh/BerliozFramework/HttpClient)\n[![Total Downloads](https://img.shields.io/packagist/dt/berlioz/http-client.svg?style=flat-square)](https://packagist.org/packages/berlioz/http-client)\n\n**Berlioz HTTP Client** is a PHP library to request HTTP server with continuous navigation, including cookies,\nsessions... Implements PSR-18 (HTTP Client), PSR-7 (HTTP message interfaces) and PSR-17 (HTTP Factories) standards.\n\n## Installation\n\n### Composer\n\nYou can install **Berlioz HTTP Client** with [Composer](https://getcomposer.org/), it's the recommended installation.\n\n```bash\n$ composer require berlioz/http-client\n```\n\n### Dependencies\n\n- **PHP** ^8.0\n- PHP libraries:\n    - **curl**\n    - **mbstring**\n    - **zlib**\n- Packages:\n    - **berlioz/http-message**\n    - **elgigi/har-parser**\n    - **psr/http-client**\n    - **psr/log**\n\n## Usage\n\n### Requests\n\n#### With RequestInterface\n\nYou can construct your own request object whose implements `RequestInterface` interface (PSR-7).\n\n```php\nuse Berlioz\\Http\\Client\\Client;\nuse Berlioz\\Http\\Message\\Request;\n\n/** @var \\Psr\\Http\\Message\\RequestInterface $request */\n$request = new Request(...);\n\n$client = new Client();\n$response = $client-\u003esendRequest($request);\n\nprint $response-\u003egetBody();\n```\n\n#### Get/Post/Patch/Put/Delete/Options/Head/Connect/Trace\n\nMethods are available to do request with defined HTTP method:\n\n- `Client::get(...)`\n- `Client::post(...)`\n- `Client::patch(...)`\n- `Client::put(...)`\n- `Client::delete(...)`\n- `Client::options(...)`\n- `Client::head(...)`\n- `Client::connect(...)`\n- `Client::trace(...)`\n\nExample with `Client::get()`:\n\n```php\nuse Berlioz\\Http\\Client\\Client;\n\n$client = new Client();\n$response = $client-\u003eget('https://getberlioz.com');\n\nprint $response-\u003egetBody();\n```\n\nYou also can pass HTTP method in argument to `Client::request(...)` method:\n\n```php\nuse Berlioz\\Http\\Client\\Client;\n\n$client = new Client();\n$response = $client-\u003erequest('get', 'https://getberlioz.com');\n\nprint $response-\u003egetBody();\n```\n\nEach method accept an array of options with `$options` argument.\nList of options:\n\n- **baseUri** (string): Base of URI if not given in requests\n- **followLocation** (bool): Follow redirections (default: true)\n- **followLocationLimit** (int): Limit location to follow\n- **sleepTime** (int): Sleep time between requests (ms) (default: 0)\n- **logFile** (string): Log file name (only file name, not path)\n- **exceptions** (bool): Throw exceptions on error (default: true)\n- **cookies** (null|false|CookiesManager): NULL: to use default cookie manager; FALSE: to not use cookies; a CookieManager object to use\n- **callback** (callable):  Callback after each request\n- **headers** (array): Default headers\n\nOptions passed in argument replace default options of client.\n\n### Session\n\nThe session is accessible with method `Client::getSession()`.\n\n#### History\n\nThe browsing history is saved in the session. If you serialize the object `Session`, the history is preserve.\n\nThe method `Session::getHistory()` returns an `History` object:\n\n```php\nuse Berlioz\\Http\\Client\\Client;\n\n$client = new Client();\n$history = $client-\u003egetSession()-\u003egetHistory();\n```\n\n#### Cookies\n\nA cookie manager is available to manage cookies of session and between requests. The manager is available\nwith `Session::getCookies()` method.\n\nIf you serialize the object `Session`, the cookies are preserves.\n\n#### HAR file\n\nHAR file of session is accessible with method `Session::getHar()`.\n\nIf you serialize the object `Session`, the HAR is preserved.\n\nRefers to the documentation of **elgigi/har-parser** library: https://github.com/ElGigi/HarParser\n\n### Adapters\n\n#### Usage\n\nDefault adapter used by library is `CurlAdapter` (if CURL extension is installed), else the `StreamAdapter` is used.\n\nYou can specify adapters to the client constructor, with argument `adapter`:\n\n```php\nuse Berlioz\\Http\\Client\\Client;\nuse Berlioz\\Http\\Client\\Adapter;\n\n$client = new Client(adapter: new Adapter\\CurlAdapter(), adapter: new Adapter\\StreamAdapter());\n```\n\nThe first specified adapter is the default adapter.\n\nIf you want force an adapter for a request, you can pass is name in the request options:\n\n```php\nuse Berlioz\\Http\\Client\\Client;\nuse Berlioz\\Http\\Client\\Adapter;\n\n$client = new Client(adapter: new Adapter\\CurlAdapter(), adapter: new Adapter\\StreamAdapter());\n$client-\u003eget('https://getberlioz.com', options: ['adapter' =\u003e 'stream']);\n```\n\n#### List\n\nList of adapters:\n\n- **curl**: `Berlioz\\Http\\Client\\Adapter\\CurlAdapter`\n- **stream**: `Berlioz\\Http\\Client\\Adapter\\StreamAdapter`\n- **har**: `Berlioz\\Http\\Client\\Adapter\\HarAdapter`\n\n#### HarAdapter\n\nThe `HarAdapter` is specially made to simulate a navigation, coming from a desktop browser for example.\n\nIt's very useful for test units. You only need to store your cleaned HAR file into your repository to launch tests with\nsimulated HTTP dialogs.\n\n```php\nuse Berlioz\\Http\\Client\\Client;\nuse Berlioz\\Http\\Client\\Adapter\\HarAdapter;\nuse ElGigi\\HarParser\\Parser;\n\n// Create HAR object from library `elgigi/har-parser`\n$har = (new Parser())-\u003eparse('/path/of/my/file.har', contentIsFile: true);\n\n$client = new Client(adapter: new HarAdapter(har: $har));\n$client-\u003eget('https://getberlioz.com'); // Get response from HAR object, without making an HTTP request\n```\n\nHar adapter accept an option `strict` (default: `false`) to force the way of navigation.\n\n#### Create an adapter\n\nYou can create an adapter for your project.\nYou must implement the interface `Berlioz\\Http\\Client\\Adapter\\AdapterInterface`.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberliozframework%2Fhttpclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fberliozframework%2Fhttpclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberliozframework%2Fhttpclient/lists"}