Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Utilize Symfony’s PSR Factory #31018

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -128,6 +128,7 @@
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).",
"moontoast/math": "Required to use ordered UUIDs (^1.1).",
"nyholm/psr7": "Required to use PSR-7 bridging features (^1.2).",
"pda/pheanstalk": "Required to use the beanstalk queue driver (^4.0).",
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0).",
Expand Down
22 changes: 19 additions & 3 deletions src/Illuminate/Routing/RoutingServiceProvider.php
Expand Up @@ -7,10 +7,13 @@
use Illuminate\Contracts\View\Factory as ViewFactoryContract;
use Illuminate\Routing\Contracts\ControllerDispatcher as ControllerDispatcherContract;
use Illuminate\Support\ServiceProvider;
use Nyholm\Psr7\Factory\Psr17Factory;
use Nyholm\Psr7\Response as NyholmPsrResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
use Zend\Diactoros\Response as PsrResponse;
ivannovak marked this conversation as resolved.
Show resolved Hide resolved
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
use Zend\Diactoros\Response as ZendPsrResponse;

class RoutingServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -128,7 +131,15 @@ protected function registerRedirector()
protected function registerPsrRequest()
{
$this->app->bind(ServerRequestInterface::class, function ($app) {
return (new DiactorosFactory)->createRequest($app->make('request'));
if (class_exists(PsrHttpFactory::class)) {
$psr17Factory = new Psr17Factory;

return (new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory))
->createRequest($app->make('request'));
}
if (class_exists(DiactorosFactory::class)) {
return (new DiactorosFactory)->createRequest($app->make('request'));
}
});
}

Expand All @@ -140,7 +151,12 @@ protected function registerPsrRequest()
protected function registerPsrResponse()
{
$this->app->bind(ResponseInterface::class, function () {
return new PsrResponse;
if (class_exists(NyholmPsrResponse::class)) {
return new NyholmPsrResponse;
}
if (class_exists(ZendPsrResponse::class)) {
return new ZendPsrResponse;
}
GrahamCampbell marked this conversation as resolved.
Show resolved Hide resolved
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Routing/composer.json
Expand Up @@ -39,7 +39,8 @@
},
"suggest": {
"illuminate/console": "Required to use the make commands (^6.0).",
"symfony/psr-http-message-bridge": "Required to psr7 bridging features (^1.2)."
"nyholm/psr7": "Required to use PSR-7 bridging features (^1.2).",
GrahamCampbell marked this conversation as resolved.
Show resolved Hide resolved
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^1.2)."
GrahamCampbell marked this conversation as resolved.
Show resolved Hide resolved
},
"config": {
"sort-packages": true
Expand Down