php-http/plugins
Deprecated plugin collection for HTTPlug (php-http/plugins). Since v1.1 most plugins moved to php-http/client-common; logger, cache, and stopwatch live in separate packages. Use this package only for legacy compatibility.
php-http/client-common and standalone plugins (e.g., php-http/logger-plugin, php-http/cache-plugin). This eliminates redundancy with Laravel’s built-in Http client and aligns with modern PHP-HTTP standards.php-http/client-common (or symfony/http-client) removes legacy baggage and leverages actively maintained libraries. Laravel’s Http facade already uses symfony/http-client under the hood, reducing the need for this package entirely.php-http).PluginClient with Http\Client\Common\PluginClient (from php-http/client-common).php-http/logger-plugin).HttpClient).symfony/http-client (used by Laravel) is now the recommended path, as it’s natively supported and actively maintained.php-http/client-common may conflict with Laravel’s bundled guzzlehttp/guzzle or symfony/http-client.php-http ecosystem.php-http equivalent (e.g., LoggerPlugin → php-http/logger-plugin).symfony/http-client extensions.Http client.php-http ecosystem is the de facto standard for PHP HTTP clients.PluginClient middlewares and prioritize migration of high-impact ones (e.g., auth, retries).Http client replace this entirely?
Http facade already uses symfony/http-client, which supports plugins natively.Http client or use symfony/http-client directly with HttpClientInterface.http-interop/http-client (deprecated) and enforce php-http/client-common or symfony/http-client.php-http: Replace PluginClient with Http\Client\Common\PluginClient + individual plugins (e.g., CachePlugin, LoggerPlugin).Http client (backed by symfony/http-client) with custom middleware or symfony/http-client plugins.php-http equivalents, rewrite them as Laravel middleware or symfony/http-client extensions.Http client or symfony/http-client directly.PluginClient usages and middlewares in the codebase.php-http equivalents (see plugin migration guide).symfony/http-client vs. current setup.http-interop/http-client and add:
composer require php-http/client-common php-http/logger-plugin php-http/cache-plugin
symfony/http-client (recommended for Laravel):
composer require symfony/http-client
PluginClient with Http\Client\Common\PluginClient:
use Http\Client\Common\PluginClient;
use Http\Client\Common\Plugin\LoggerPlugin;
use Http\Client\Common\Plugin\CachePlugin;
use Http\Client\Common\Plugin\RetryPlugin;
use Http\Client\Common\Plugin\HeaderAppendPlugin;
use Http\Client\Common\Plugin\HeaderNormalizerPlugin;
use Http\Client\Common\Plugin\BaseUriPlugin;
use Http\Client\Common\Plugin\ExceptionPlugin;
use Http\Client\Common\Plugin\TimeoutPlugin;
use Http\Client\Common\Plugin\HistoryPlugin;
use Http\Client\Common\Plugin\StatisticsPlugin;
use Http\Client\Common\Plugin\BaseUrlPlugin;
use Http\Client\Common\Plugin\ContentLengthPlugin;
use Http\Client\Common\Plugin\RedirectPlugin;
use Http\Client\Common\Plugin\StreamPlugin;
$client = new PluginClient(
new SymfonyClient(), // Laravel's HttpClient instance
[
new LoggerPlugin(),
new CachePlugin(),
// ... other plugins
]
);
Http client with symfony/http-client plugins:
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Component\HttpClient\RetryMiddleware;
$client = \Http\Client\Common\PluginClient::create(
HttpClientInterface::create(),
[new RetryMiddleware()]
);
Http::get() calls with the new client:
$response = $client->sendRequest(new Request('GET', 'https://api.example.com'));
Http facade, use middleware or symfony/http-client directly:
$response = Http::withOptions(['http_client' => $client])->get('...');
http-interop/http-client from composer.json.php-http/client-common supports PHP 7.4+ (aligns with Laravel 8+).symfony/http-client.symfony/http-client.PluginClient middlewares have direct php-http counterparts (e.g., LoggerPlugin → php-http/logger-plugin).symfony/http-client extensions).PluginClient::withConfig() to enforce order:
$client = new PluginClient($baseClient, $plugins, $config);
http-interop/http-client with php-http/client-common + required plugins.AppServiceProvider):
$this->app->singleton('http.plugin_client', function ($app) {
return new PluginClient(
$app->make('http.client'), // Laravel's HttpClient
[$app->make(LoggerPlugin::class)],
new MessageFactory()
);
});
How can I help you explore Laravel packages today?