HTTPlug, the HTTP client abstraction for PHP

Overview

HTTPlug

Latest Version Software License Build Status Code Coverage Quality Score Total Downloads

Slack Status Email

HTTPlug, the HTTP client abstraction for PHP.

Intro

HTTP client standard built on PSR-7 HTTP messages. The HTTPlug client interface is compatible with the official standard for the HTTP client interface, PSR-18. HTTPlug adds an interface for asynchronous HTTP requests, which PSR-18 does not cover.

Since HTTPlug has already been widely adopted and a whole ecosystem has been built around it, we will keep maintaining this package for the time being. HTTPlug 2.0 and newer extend the PSR-18 interface to allow for a convenient migration path.

New client implementations and consumers should use the PSR-18 interfaces directly. In the long term, we expect PSR-18 to completely replace the need for HTTPlug.

History

HTTPlug is the official successor of the ivory http adapter. HTTPlug is a predecessor of PSR-18

Install

Via Composer

$ composer require php-http/httplug

Documentation

Please see the official documentation.

Testing

$ composer test

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Namespace of all packages

    Namespace of all packages

    I would like to propose the following namespace for our different package (goal is to have, in the future, possibility to assemble all package into a single one with subsplit):

    • Httplug : Http\Client (not changed)
    • Promise : Http\Promise (not changed)
    • Message-Factory: Http\Message (not changed)
    • Tools : Http\Tools (Http\Client\Tools actually)
    • Utils : Http\Utils (Http\Client\Utils actually)
    • Plugin : Http\Plugin (Http\Client\Plugin actually)
    • Adapters (guzzle / react / ...) : Http\Adapters\[Adapter Name], so Guzzle6 will have this namespace for example : Http\Adapters\Guzzle6 (instead of Http\Adapter actually)
    • Clients (socket / curl / ...) : Http\Clients\[Client Name], so Socket will have Http\Clients\Socket
    • Discovery : Http\Discovery (not changed)

    WDYT ?

    question 
    opened by joelwurtz 49
  • New name

    New name

    The PHP HTTP client is an abstraction layer to separate general purpose libraries from concrete client implementations in order to make them move flexible. It is the successor of the Ivory HTTP adapter and we should not use Ivory anymore to keep it separate from all the other things under the Ivory name that do unrelated things.

    Just calling it "php http" makes it impossible to find this thing in google, as almost website about web development has these keywords. We should have some additional name that makes it findable.

    Ideas so far:

    • CPHC/APHC for common php http client / abstract php http client by @dbu
    • Klant by @hannesvdvreken
    • Raspberry by @Zarkonnen
    • Hunlet by @patkar
    • Tupac by @greg0ire
    • Straw by @Pierstoval
    • Httplug (and variations) by @sandermarechal
    • Phetch by @sandermarechal
    opened by sagikazarmark 46
  • Implement remaining adapters

    Implement remaining adapters

    • [x] Guzzle 6 (Implemented by @ddeboer)
    • [x] Guzzle 5 (Implemented by @sagikazarmark and @Nyholm)
    • [x] ~~Guzzle 4 (EOL)~~
    • [x] ~~Guzzle 3 (EOL)~~
    • [x] Curl (Implemented by @mekras)
    • [x] Buzz (Implemented by @Nyholm)
    • [x] Cake (Implemented by @joelwurtz)
    • [x] ~~HTTPful~~ (Not important at the moment)
    • [x] ~~PECL~~ (Not important at the moment)
    • [x] React (Implemented by @shulard)
    • [x] Socket (Implemented by @joelwurtz)
    • [x] ~~Zend 1~~ (too old)
    • [x] Zend 2 (Implemented by @joelwurtz)
    • [x] ~~File get contents (?)~~ (Not important at the moment)
    • [x] ~~Fopen (?)~~ (Not important at the moment)
    • [x] ~~League Event (decorator)~~ (Hard to use with immutable messages)
    • [x] ~~Symfony Event (decorator)~~ (Hard to use with immutable messages)
    • [x] ~~Stopwatch (decorator)~~ (Implemented as plugin)
    enhancement 
    opened by sagikazarmark 44
  • Avoiding dependency hell

    Avoiding dependency hell

    Currently each adapter of php-http will have his own repository, i'm afraid to see a big complexity if some days an interface need to be changed and all adapter will then have to be updated and match against the new version.

    My proposal is to have all the code / issue / ... on one repository and make sub view (like symfony with its components), so a PR for updating a interface will also contain the modification for all corresponding adapter / client.

    opened by joelwurtz 34
  • Future of the project

    Future of the project

    Hey @php-http/owners, @dbu and @ddeboer,

    For the last few months I've made some progress with this project. Sadly, @egeloen disappeared so we couldn't work together or discuss the phases of the project. I really appreciate the help of everyone who participated. I think this will be a great part of the PHP community once it gets stable. I am completely commited to the project, and I already have some feedback that other projects would like to rely on it.

    As said, @egeloen does not really respond to any of my attempts to contact him. @dbu agreed to contact him (or at least try it). Until then, I would like to make progress with the project and reach at least an alpha phase, so other projects can start working with the interface. This does not mean that @egeloen is not part of the team anymore, but we have been waiting for four months now...

    The current proposal of the interfaces is in the terminology branch. Currently exceptions are being refactored. After that I am going to merge the terminology branch.

    My purpose is to reach alpha till the end of September.

    opened by sagikazarmark 33
  • Repository/package cleanup

    Repository/package cleanup

    Now, that we are merging repositories together, the question comes up whether we should remove the deprecated repositories or not.

    Pros:

    • less repository, less confusion
    • less repository, less maintenance

    Cons:

    • some of the repositories have already been tagged, which means they COULD be used somewhere. Fortunately packagist gives us information about dependent packages.
    • we lose issues, PRs, history (which is probably not a big deal in the current phase of the project)
    enhancement question 
    opened by sagikazarmark 29
  • Async Http Client

    Async Http Client

    See #74 and #75 discussion for a more detailed description.

    This PR intend to add asynchronous support for httplug by adding a new interface HttpAsyncClient which allow to send an asynchronous request and return a promise for the response.

    The current Promise interface follow specification of https://promisesaplus.com/ from an user point of view (there is no method for fulfilling or rejecting the promise, it should be up to the implementation user only care on how to handle the return and not on how to resolve the promise)

    opened by joelwurtz 29
  • List of possible options

    List of possible options

    We need to have a list of possible values for the options parameter. These are general options which should work with ALL the clients.

    Possible options:

    • timeout [0]
    • exceptions [false]: whether the user wants 4xx and 5xx responses to be converted to exceptions
    • base_uri [null]: from #36
    opened by sagikazarmark 26
  • Terminology

    Terminology

    This PR tries to solve #38

    Some points to discuss:

    • [x] Exceptions in the package: concrete implementations? Exception naming?
    • [x] Interface names: PsrClient, HttpClient, Client? (proposed by @dbu HttpPsrClient, HttpMethodsClient, HttpClient)
    • [x] Add ClientTemplate: better name?

    To do before merging:

    • ~~Squash commits!!!!!!!~~

    To do after merging:

    • [ ] Move the package to client (preserve the package here as well for historical reasons (0.1 release)?)
    enhancement help wanted 
    opened by sagikazarmark 26
  • Add specific http promise

    Add specific http promise

    | Q | A | | --- | --- | | Bug fix? | yes | | New feature? | yes | | BC breaks? | no | | Deprecations? | no | | Related tickets | https://github.com/php-http/client-common/issues/34 | | Documentation | | | License | MIT |

    This is not something that is meant to merge, it's to offer a point of view on this ticket https://github.com/php-http/client-common/issues/34 we should accept this or not based on the final decision.

    opened by joelwurtz 23
  • Conventional way to configure client

    Conventional way to configure client

    Httplug interfaces does not provide a way to configure client behaviour such as timeouts, SSL settings or other parameters that cannot be set in the RequestInterface.

    For example. In dev environments we want our HTTP client to ignore SSL errors. But we can do this only when instantiating particular implementation. It has two disadvantages:

    1. we can't use HttpClientDiscovery;
    2. code, where the client is introduced through the interface, can't change these settings.
    opened by mekras 23
  • State of async HTTP clients and promises

    State of async HTTP clients and promises

    I'd say PSR-18 was pretty successful. Guzzle, Buzz, Symfony and others support it natively, and some others support it via adapters.

    However, this still doesn't help you very much if you need async HTTP requests. Although there is HttpAsyncClient in this package, it is still not standard, not many clients support it without adapters and some adapters seem to be outdated: Guzzle adapters do not support Guzzle 7 yet (which added PSR-18 support but does not support HttpAsyncClient promises), Buzz does not support HttpAsyncClient and adapter was discontinued... From popular clients, only Symfony supports it natively. This will become better when Guzzle 7 HttpAsyncClient adapter is released, but still not perfect.

    So, will async HTTP clients (and promises which are requirement for async HTTP client PSR) ever become PSR standard and be directly supported in popular clients? What is current state of becoming standard? From quick (possibly incomplete) search through docs and closed issues, it seems there were some plans to make promise, event loop and async HTTP client PSR. However, discussions about this seem to have ended few years ago and some were "put on hold" until future.

    opened by filips123 13
Releases(2.3.0)
  • 2.3.0(Feb 21, 2022)

  • 2.2.0(Jul 13, 2020)

  • 2.1.0(Dec 27, 2019)

  • v2.0.0(Oct 31, 2018)

    After two years of work the FIG finally accepted our proposal for HTTP Client standard as PSR-18. This is a huge step in the life of HTTPlug.

    Many thanks to @Nyholm who spearheaded the effort from the very first moment and worked extremely hard to pull this off. Thanks to the working group and everyone else, who made this possible.

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Aug 31, 2016)

    During the development of plugins we faced a problem with exceptions thrown in plugins.

    Any exceptions not implementing Http\Client\Exception ended up in an invalid argument error because of these lines:

    https://github.com/php-http/promise/blob/v1.0.0/src/RejectedPromise.php#L36-L38

    This type leak allowed to inject an exception to be passed to the onRejected callback of a Promise.

    In the current release we introduced HTTP specific promises which does not catch all exceptions, but HTTP ones. Every other exception will be thrown immediately.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta(Dec 17, 2015)

    This release brings a cleaner exception concept which is documented directly in the interfaces.

    There is also an initial support for discovering HTTP Clients using Puli.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-alpha3(Dec 13, 2015)

  • v1.0.0-alpha2(Nov 16, 2015)

  • v1.0.0-alpha(Oct 26, 2015)

    Yay, finally we got here.

    After 7 months of work, we are proud to present our HTTP Client contract to the world.

    Although this started as a project providing adapters to already existing HTTP Clients, the goal changed to a more general approach.

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Jun 3, 2015)

Owner
The PHP HTTP group
Collection of HTTP related packages. Our main product: HTTPlug
The PHP HTTP group
Declarative HTTP Clients using Guzzle HTTP Library and PHP 8 Attributes

Waffler How to install? $ composer require waffler/waffler This package requires PHP 8 or above. How to test? $ composer phpunit Quick start For our e

Waffler 3 Aug 26, 2022
Guzzle, an extensible PHP HTTP client

Guzzle, PHP HTTP client Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services. Simple interf

Guzzle 22.3k Jan 2, 2023
A Chainable, REST Friendly, PHP HTTP Client. A sane alternative to cURL.

Httpful Httpful is a simple Http Client library for PHP 7.2+. There is an emphasis of readability, simplicity, and flexibility – basically provide the

Nate Good 1.7k Dec 21, 2022
PHP's lightweight HTTP client

Buzz - Scripted HTTP browser Buzz is a lightweight (<1000 lines of code) PHP 7.1 library for issuing HTTP requests. The library includes three clients

Kris Wallsmith 1.9k Jan 4, 2023
Unirest in PHP: Simplified, lightweight HTTP client library.

Unirest for PHP Unirest is a set of lightweight HTTP libraries available in multiple languages, built and maintained by Mashape, who also maintain the

Kong 1.3k Dec 28, 2022
↪️ Bypass for PHP creates a custom HTTP Server to return predefined responses to client requests

Bypass for PHP provides a quick way to create a custom HTTP Server to return predefined responses to client requests.Useful for tests with Pest PHP or PHPUnit.

CiaReis 101 Dec 1, 2022
A PHP proxy to solve client browser HTTP CORS(cross-origin) restrictions.

cors-bypass-proxy A PHP proxy to solve client browser HTTP CORS(cross-origin) restrictions. A simple way to solve CORS issue when you have no access t

Gracious Emmanuel 15 Nov 17, 2022
Zenscrape package is a simple PHP HTTP client-provider that makes it easy to parsing site-pages

Zenscrape package is a simple PHP HTTP client-provider that makes it easy to parsing site-pages

Andrei 3 Jan 17, 2022
Async HTTP/1.1+2 client for PHP based on Amp.

This package provides an asynchronous HTTP client for PHP based on Amp. Its API simplifies standards-compliant HTTP resource traversal and RESTful web

AMPHP 641 Dec 19, 2022
Simple HTTP cURL client for PHP 7.1+ based on PSR-18

Simple HTTP cURL client for PHP 7.1+ based on PSR-18 Installation composer require sunrise/http-client-curl QuickStart composer require sunrise/http-f

Sunrise // PHP 15 Sep 5, 2022
Event-driven, streaming HTTP client and server implementation for ReactPHP

HTTP Event-driven, streaming HTTP client and server implementation for ReactPHP. This HTTP library provides re-usable implementations for an HTTP clie

ReactPHP 640 Dec 29, 2022
HTTP header kit for PHP 7.1+ (incl. PHP 8) based on PSR-7

HTTP header kit for PHP 7.1+ (incl. PHP 8) based on PSR-7 Installation composer require sunrise/http-header-kit How to use? HTTP Header Collection Mor

Sunrise // PHP 63 Dec 31, 2022
Express.php is a new HTTP - Server especially made for RESTful APIs written in PHP.

express.php Express.php is a new HTTP - Server especially made for RESTful APIs written in PHP. Features Fast The Library is handles requests fast and

null 5 Aug 19, 2022
Requests for PHP is a humble HTTP request library. It simplifies how you interact with other sites and takes away all your worries.

Requests for PHP Requests is a HTTP library written in PHP, for human beings. It is roughly based on the API from the excellent Requests Python librar

null 3.5k Dec 31, 2022
Requests for PHP is a humble HTTP request library. It simplifies how you interact with other sites and takes away all your worries.

Requests for PHP Requests is a HTTP library written in PHP, for human beings. It is roughly based on the API from the excellent Requests Python librar

null 3.5k Dec 31, 2022
PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs

PHP Curl Class: HTTP requests made easy PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs. Installation Requirements Quic

null 3.1k Jan 5, 2023
A simple PHP Toolkit to parallel generate combinations, save and use the generated terms to brute force attack via the http protocol.

Brutal A simple PHP Toolkit to parallel generate combinations, save and use the generated terms to apply brute force attack via the http protocol. Bru

Jean Carlo de Souza 4 Jul 28, 2021
🐼 Framework agnostic package using asynchronous HTTP requests and PHP generators to load paginated items of JSON APIs into Laravel lazy collections.

Framework agnostic package using asynchronous HTTP requests and generators to load paginated items of JSON APIs into Laravel lazy collections.

Andrea Marco Sartori 61 Dec 3, 2022
Composer package providing HTTP Methods, Status Codes and Reason Phrases for PHP

HTTP Enums For PHP 8.1 and above This package provides HTTP Methods, Status Codes and Reason Phrases as PHP 8.1+ enums All IANA registered HTTP Status

Alexander Pas 72 Dec 23, 2022