{"id":13616970,"url":"https://github.com/php-http/discovery","last_synced_at":"2025-05-13T22:07:54.939Z","repository":{"id":37951888,"uuid":"36755218","full_name":"php-http/discovery","owner":"php-http","description":"Finds installed clients and message factories","archived":false,"fork":false,"pushed_at":"2024-10-02T11:20:57.000Z","size":727,"stargazers_count":1299,"open_issues_count":4,"forks_count":46,"subscribers_count":13,"default_branch":"1.x","last_synced_at":"2025-04-29T14:02:43.688Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://php-http.org","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/php-http.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","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":"2015-06-02T19:03:26.000Z","updated_at":"2025-04-22T08:45:23.000Z","dependencies_parsed_at":"2024-04-22T08:59:26.558Z","dependency_job_id":"e7a2e972-8b62-4bd5-a53f-23f0e0b5e601","html_url":"https://github.com/php-http/discovery","commit_stats":{"total_commits":218,"total_committers":38,"mean_commits":"5.7368421052631575","dds":0.7155963302752293,"last_synced_commit":"1ce09e799044cb5255d735991217408611c67ec4"},"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-http%2Fdiscovery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-http%2Fdiscovery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-http%2Fdiscovery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-http%2Fdiscovery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-http","download_url":"https://codeload.github.com/php-http/discovery/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036821,"owners_count":22003654,"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-08-01T20:01:35.421Z","updated_at":"2025-05-13T22:07:49.919Z","avatar_url":"https://github.com/php-http.png","language":"PHP","readme":"# HTTPlug Discovery\n\n[![Latest Version](https://img.shields.io/github/release/php-http/discovery.svg?style=flat-square)](https://github.com/php-http/discovery/releases)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Tests](https://github.com/php-http/discovery/actions/workflows/ci.yml/badge.svg?branch=1.x)](https://github.com/php-http/discovery/actions/workflows/ci.yml?query=branch%3A1.x)\n[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/discovery.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/discovery)\n[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/discovery.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/discovery)\n[![Total Downloads](https://img.shields.io/packagist/dt/php-http/discovery.svg?style=flat-square)](https://packagist.org/packages/php-http/discovery)\n\n**This library provides auto-discovery and auto-installation of well-known PSR-17, PSR-18 and HTTPlug implementations.**\n\n\n## Install\n\nVia Composer\n\n``` bash\ncomposer require php-http/discovery\n```\n\n\n## Usage as a library author\n\nPlease see the [official documentation](http://php-http.readthedocs.org/en/latest/discovery.html).\n\nIf your library/SDK needs a PSR-18 client, here is a quick example.\n\nFirst, you need to install a PSR-18 client and a PSR-17 factory implementations.\nThis should be done only for dev dependencies as you don't want to force a\nspecific implementation on your users:\n\n```bash\ncomposer require --dev symfony/http-client\ncomposer require --dev nyholm/psr7\n```\n\nThen, you can disable the Composer plugin embeded in `php-http/discovery`\nbecause you just installed the dev dependencies you need for testing:\n\n```bash\ncomposer config allow-plugins.php-http/discovery false\n```\n\nFinally, you need to require `php-http/discovery` and the generic implementations\nthat your library is going to need:\n\n```bash\ncomposer require 'php-http/discovery:^1.17'\ncomposer require 'psr/http-client-implementation:*'\ncomposer require 'psr/http-factory-implementation:*'\n```\n\nNow, you're ready to make an HTTP request:\n\n```php\nuse Http\\Discovery\\Psr18Client;\n\n$client = new Psr18Client();\n\n$request = $client-\u003ecreateRequest('GET', 'https://example.com');\n$response = $client-\u003esendRequest($request);\n```\n\nInternally, this code will use whatever PSR-7, PSR-17 and PSR-18 implementations\nthat your users have installed.\n\n\n## Usage as a library user\n\nIf you use a library/SDK that requires `php-http/discovery`, you can configure\nthe auto-discovery mechanism to use a specific implementation when many are\navailable in your project.\n\nFor example, if you have both `nyholm/psr7` and `guzzlehttp/guzzle` in your\nproject, you can tell `php-http/discovery` to use `guzzlehttp/guzzle` instead of\n`nyholm/psr7` by running the following command:\n\n```bash\ncomposer config extra.discovery.psr/http-factory-implementation GuzzleHttp\\\\Psr7\\\\HttpFactory\n```\n\nThis will update your `composer.json` file to add the following configuration:\n\n```json\n{\n    \"extra\": {\n        \"discovery\": {\n            \"psr/http-factory-implementation\": \"GuzzleHttp\\\\Psr7\\\\HttpFactory\"\n        }\n    }\n}\n```\n\nDon't forget to run `composer install` to apply the changes, and ensure that\nthe composer plugin is enabled:\n\n```bash\ncomposer config allow-plugins.php-http/discovery true\ncomposer install\n```\n\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n\n## Contributing\n\nPlease see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html).\n\n\n## Security\n\nIf you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org).\n\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-http%2Fdiscovery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-http%2Fdiscovery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-http%2Fdiscovery/lists"}