1656641760
HTTPlug, the HTTP client abstraction for PHP.
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.
HTTPlug is the official successor of the ivory http adapter. HTTPlug is a predecessor of PSR-18
Via Composer
$ composer require php-http/httplug
Please see the official documentation.
$ composer test
Author: php-http
Source Code: https://github.com/php-http/httplug
License: MIT license
1656641760
HTTPlug, the HTTP client abstraction for PHP.
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.
HTTPlug is the official successor of the ivory http adapter. HTTPlug is a predecessor of PSR-18
Via Composer
$ composer require php-http/httplug
Please see the official documentation.
$ composer test
Author: php-http
Source Code: https://github.com/php-http/httplug
License: MIT license
1597820991
Looking to develop a PHP based website from scratch or revamp your existing website?
HourlyDeveloper.io has always been an industry leader for companies and business owners looking to hire PHP web developer. By choosing to Hire PHP Developer from our company, you can always expect the best results. Our PHP services and solutions are always flexible which means that no matter the nature of your project, you can always count on us for getting the best PHP expertise.
Consult with our experts: https://bit.ly/3aEGxPy
#hire php developer #php developer #php development company #php development services #php development #php
1649234520
HTTPlug
HTTPlug, the HTTP client abstraction for PHP.
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.
HTTPlug is the official successor of the ivory http adapter. HTTPlug is a predecessor of PSR-18
Via Composer
$ composer require php-http/httplug
Please see the official documentation.
$ composer test
The MIT License (MIT). Please see License File for more information.
Author: php-http
Source Code: https://github.com/php-http/httplug
License: MIT License
1648769040
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: FileGetContents
, Curl
and MultiCurl
. The MultiCurl
supports batch requests and HTTP2 server push.
Install by running:
composer require kriswallsmith/buzz
You do also need to install a PSR-17 request/response factory. Buzz uses that factory to create PSR-7 requests and responses. Install one from this list.
Example:
composer require nyholm/psr7
This page will just show you the basics, please read the full documentation.
use Buzz\Browser;
use Buzz\Client\FileGetContents;
$client = new FileGetContents(new Psr17ResponseFactory());
$browser = new Browser($client, new Psr17RequestFactory());
$response = $browser->get('https://www.google.com');
echo $browser->getLastRequest()."\n";
// $response is a PSR-7 object.
echo $response->getStatusCode();
You can also use the low-level HTTP classes directly.
use Buzz\Client\FileGetContents;
$request = new PSR7Request('GET', 'https://google.com/foo');
$client = new FileGetContents(new Psr17ResponseFactory());
$response = $client->sendRequest($request, ['timeout' => 4]);
echo $response->getStatusCode();
The two new Psr17ResponseFactory()
and new Psr17RequestFactory()
are placeholders for whatever PSR-17 factory you choose. If you use nyholm/psr7
then the example above would start like:
use Buzz\Browser;
use Buzz\Client\FileGetContents;
use Nyholm\Psr7\Factory\Psr17Factory;
$client = new FileGetContents(new Psr17Factory());
$browser = new Browser($client, new Psr17Factory());
$response = $browser->get('https://www.google.com');
Buzz MultiCurl client support HTTP2 server push.
use Buzz\Client\MultiCurl;
use Nyholm\Psr7\Factory\Psr17Factory;
use Nyholm\Psr7\Request;
$client = new MultiCurl(new Psr17Factory());
$start = microtime(true);
$response = $client->sendRequest(new Request('GET', 'https://http2.golang.org/serverpush', [], null, '2.0'));
$timeFirstRequest = microtime(true) - $start;
// Parse response to find asset version.
$body = $response->getBody()->__toString();
$id = null;
if (preg_match('#/serverpush/static/style.css\?([0-9]+)#sim', $body, $matches)) {
$id = $matches[1];
}
// Make two new requests
$start = microtime(true);
$client->sendRequest(new Request('GET', 'https://http2.golang.org/serverpush/static/style.css?'.$id));
$client->sendRequest(new Request('GET', 'https://http2.golang.org/serverpush/static/playground.js?'.$id));
$timeOtherRequests = microtime(true) - $start;
echo 'First: '.$timeFirstRequest."\n";
echo 'Other: '.$timeOtherRequests."\n";
Since the two other requests was pushed, we spend no time fetching those.
First: 1.04281
Other: 0.00027
You can configure what request you want to accept as pushed with the push_function_callback
option.
Buzz was created by Kris Wallsmith back in 2010. The project grown very popular over the years with more than 7 million downloads.
Since August 2017 Tobias Nyholm is maintaining this library. The idea of Buzz will still be the same, we should have a simple API and mimic browser behavior for easy testing. We should not reinvent the wheel and we should not be as powerful and flexible as other clients (ie Guzzle). We do, however, take performance very seriously.
We do love PSRs and this is a wish list of what PSR we would like to support:
Since the release of 1.0 Buzz has reached its goal of being a lightweight client that covers 90% of all use cases. There are no plans to actively develop new features or change the existing API. There are alternatives for people that wants an more actively maintained HTTP clients. One that is particularly popular and got a big community behind it is the
Symfony HTTP Client.
Buzz is great because it is small, simple and yet flexible. We are always happy to receive bug reports and bug fixes. We are also looking forward to review a pull request with a new middleware, especially if the middleware covers a common use case.
We will probably not accept any configuration option or feature to any of the clients or the Browser.
We take backwards compatibility very seriously as you should do with any open source project. We strictly follow Semver. Please note that Semver works a bit different prior version 1.0.0. Minor versions prior 1.0.0 are allow to break backwards compatibility.
Being greatly inspired by Symfony's bc promise, we have adopted their method of deprecating classes, interfaces and functions.
There are 2 kinds of tests for this library; unit tests and integration tests. They can be run separably by:
./vendor/bin/phpunit --testsuite Unit
./vendor/bin/phpunit --testsuite Integration
The integration tests makes real HTTP requests to a webserver. There are two different webservers used by our integration tests. A real Nginx server and PHP's built in webserver. The tests that runs with PHP's webserver are provided by php-http/client-integration-tests
.
To start the server, open terminal A and run:
./vendor/bin/http_test_server
The other type of integration tests are using Nginx. We use Docker to start the Nginx server.
docker build -t buzz/tests .
docker run -d -p 127.0.0.1:8022:80 buzz/tests
You are now ready to run the integration tests
./vendor/bin/phpunit --testsuite Integration
To use HTTP/2 server push you need to run the very latest PHP version. PHP also need to use cUrl > 7.61.1 and be compiled with libnghttp2. You can use docker:
composer update
docker run -it --rm --name php-latest -v "$PWD":/usr/src/myapp -w /usr/src/myapp tommymuehle/docker-alpine-php-nightly \
php vendor/bin/phpunit tests/Integration/MultiCurlServerPushTest.php
Author: Kriswallsmith
Source Code: https://github.com/kriswallsmith/Buzz
License: MIT License
1648776480
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.
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}'
// Send an asynchronous request.
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
$promise = $client->sendAsync($request)->then(function ($response) {
echo 'I completed! ' . $response->getBody();
});
$promise->wait();
We use GitHub issues only to discuss bugs and new features. For support please refer to:
The recommended way to install Guzzle is through Composer.
composer require guzzlehttp/guzzle
Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version |
---|---|---|---|---|---|---|---|
3.x | EOL | guzzle/guzzle | Guzzle | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >= 5.3.3 |
4.x | EOL | guzzlehttp/guzzle | GuzzleHttp | [v4][guzzle-4-repo] | N/A | No | >= 5.4 |
5.x | EOL | guzzlehttp/guzzle | GuzzleHttp | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 |
6.x | Security fixes | guzzlehttp/guzzle | GuzzleHttp | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 |
7.x | Latest | guzzlehttp/guzzle | GuzzleHttp | [v7][guzzle-7-repo] | [v7][guzzle-7-docs] | Yes | >= 7.2 |
If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see Security Policy for more information.
Available as part of the Tidelift Subscription
The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
Author: Guzzle
Source Code: https://github.com/guzzle/guzzle
License: MIT License