boson-php/symfony-http-bridge
Bridge package connecting Boson PHP with Symfony HttpFoundation, providing adapters to translate requests and responses between the two ecosystems for smoother interoperability when mixing Boson components with Symfony-based HTTP handling.
Symfony HTTP Bridge in a Laravel Context: The package is a Symfony HTTP bridge, meaning it provides utilities for HTTP client/server interactions (e.g., request/response handling, middleware, PSR-15 middleware support). Laravel already has its own HTTP stack (Symfony HTTP Foundation components under the hood), but this package could introduce duplication or inconsistencies if not carefully scoped.
Illuminate\Http and Illuminate\Pipeline already handle middleware. This package may not add significant value unless leveraging Symfony-specific features (e.g., HttpClient, ServerRequest).Key Features to Leverage:
HttpClient (if replacing Guzzle or Laravel’s HTTP client).Dependency Conflicts:
symfony/http-foundation, symfony/http-client, and psr/http-message. Laravel already bundles these (or compatible versions), but version mismatches could arise.composer require with --with-all-dependencies and resolve conflicts via composer.json overrides or Laravel’s config/app.php provider adjustments.Laravel-Specific Challenges:
Closure and Illuminate\Pipeline, not PSR-15. Adapting PSR-15 middleware to Laravel’s stack would require wrappers or custom middleware.SymfonyMiddleware::class extending ClosureMiddleware).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Version conflicts | High | Pin Symfony dependencies to Laravel’s versions or use config:clear-cache post-install. |
| Middleware incompatibility | Medium | Create adapter classes for PSR-15 ↔ Laravel middleware. |
| Unnecessary complexity | Medium | Evaluate if Laravel’s native HTTP stack suffices before adoption. |
| Limited community support | Low | Package is a subtree split with no stars; rely on Symfony docs. |
Why Symfony HTTP Bridge?
HttpClient, ServerRequest) that Laravel’s stack lacks?Http::macro, Illuminate\Http\Client)?Middleware Strategy
spatie/laravel-psr-middleware) that already solve this?Dependency Management
^10.0 (or other versions)?Performance Impact
HttpClient a drop-in replacement for Guzzle, or are there behavioral differences?Long-Term Viability
boson-php/boson, is the parent project stable? Could this become obsolete?Where It Fits in Laravel:
Http::client() with Symfony’s HttpClient (if features like retry middleware, pooling, or async requests are needed).ServerRequest/Response interfaces for interoperability with Symfony apps (e.g., in hybrid Laravel/Symfony projects).Alternatives to Consider:
Http::macro() for custom client logic.spatie/laravel-psr-middleware for PSR-15 support.Assessment Phase:
composer require boson-php/symfony-http-bridge --dry-run.Proof of Concept (PoC):
Http client with Symfony’s HttpClient for a non-critical endpoint.Gradual Rollout:
HttpClient for external API calls (if it offers superior features).Laravel Versions:
^9.0, ^10.0, and ^11.0 to ensure Symfony component versions align.config/app.php to override providers if needed:
'providers' => [
// ...
Boson\SymfonyHttpBridge\Provider::class,
],
PHP Version:
^8.1 compatibility (Laravel 10+) matches the package’s requirements.Conflict Resolution:
^6.4 is required but Laravel bundles ^6.3, use:
"extra": {
"laravel": {
"dont-discover": [
"symfony/http-client"
]
}
}
composer.json:
"require": {
"symfony/http-client": "6.4.*"
},
"conflict": {
"symfony/http-client": "!=6.4.*"
}
composer require boson-php/symfony-http-bridge
composer dump-autoload
config/app.php.namespace App\Http\Middleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
class Psr15MiddlewareWrapper implements \Illuminate\Contracts\Middleware
{
public function __construct(private MiddlewareInterface $middleware) {}
public function handle($request, \Closure $next)
{
$symfonyRequest = new SymfonyRequest($request);
$response = $this->middleware->process($symfonyRequest, new SymfonyResponse());
return new \Illuminate\Http\Response($response->getContent(), $response->getStatusCode(), $response->headers->all());
}
}
Http::get() with Symfony’s client:
use Symfony\Contracts\HttpClient\HttpClientInterface;
$client = \Boson\SymfonyHttpBridge\Client::create();
$response = $client->request('GET', 'https://api.example.com');
composer outdated.HttpClient/ServerRequest.Kernel.dd($request) to inspect ServerRequest objects in Laravel contexts.How can I help you explore Laravel packages today?