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

4.x - Improve AppFactory & ServerRequestCreatorFactory Automatic Decoration #2716

merged 4 commits into from Jun 6, 2019


Copy link

commented Jun 6, 2019

AppFactory's New Behavior
AppFactory will attempt to decorate ResponseFactory instances passed via AppFactory::create() or set via AppFactory::setResponseFactory() given that a StreamFactoryInterface has been set via AppFactory::setStreamFactory() given that Slim\Http is present.

Note that the AppFactory setters will override any of the PSR-17 factory provider automatically detected implementations.

use Slim\Factory\AppFactory;
use Your\Psr7\CustomResponseFactory;
use Your\Psr7\CustomStreamFactory;

// Set your custom StreamFactory first
$myStreamFactory = new CustomStreamFactory();

// You can use a setter for your ResponseFactory
$myCustomResponseFactory = new CustomResponseFactory();
$app = AppFactory::create();

// Or you can use the AppFactory::create() constructor parameter
$app = AppFactory::create($myCustomResponseFactory);

ServerRequestCreatorFactory's New Behavior
Similarly to AppFactory you can set a default ServerRequestCreator which implements ServerRequestCreatorInterface that will override the automatically detected server request creators present in the PSR-17 factory provider.

use Slim\Factory\AppFactory;
use Slim\Factory\ServerRequestCreatorFactory;
use Your\Psr7\CustomServerRequestCreator;

$myCustomServerRequestCreator = new CustomServerRequestCreator();

$app = AppFactory::create();

This PR effectively closes #2709, #2710, #2712 and #2713

@l0gicgate l0gicgate added the Slim 4 label Jun 6, 2019

@l0gicgate l0gicgate added this to the 4.0.0 milestone Jun 6, 2019

@l0gicgate l0gicgate force-pushed the l0gicgate:4.x-ImproveAutomaticDecoration branch from b979123 to 22f7157 Jun 6, 2019


This comment has been minimized.

Copy link

commented Jun 6, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 22f7157 on l0gicgate:4.x-ImproveAutomaticDecoration into 8dfa32d on slimphp:4.x.

@l0gicgate l0gicgate merged commit d9c8356 into slimphp:4.x Jun 6, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
coverage/coveralls Coverage remained the same at 100.0%

This comment has been minimized.

Copy link

commented Jun 6, 2019


@l0gicgate l0gicgate referenced this pull request Aug 1, 2019


Slim 4 Release #2769

@l0gicgate l0gicgate deleted the l0gicgate:4.x-ImproveAutomaticDecoration branch Aug 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.