slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.98k stars 1.95k forks source link

Slim\App::subRequest() makes difficults on using custom PSR-7 implementation #2010

Closed acgrid closed 8 years ago

acgrid commented 8 years ago

I want use my own Request implementation by registering the factory before Slim's default service provider.

However the Slim\App::subRequest() breaks everything because it instantiate Slim\Http\Request in literal and more worse, I can not override this method since its private field $container.

Suggestions I can come up with:

Reference: https://github.com/slimphp/Slim/blob/184352bc1913d7ba552ab4131d62f4730ddb0893/Slim/App.php#L495

vlakoff commented 8 years ago

About your suggestions:

acgrid commented 8 years ago

Yeah you reminded me, suggestion 2 may be awful with different constructor signature.

Then it seems that the first option is most straightforward, so I also want to question "Is there any reason this property is private?"

akrabat commented 8 years ago

I recommend just writing creating instantiating your own request and response objects and calling $app->__invoke() directly.

acgrid commented 8 years ago

Thanks for your reply. I've edited my code to avoid subRequest() and no impacts so far.