-
Notifications
You must be signed in to change notification settings - Fork 46
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
Factories #1
Comments
We can probably deprecate/remove the entire "environment" concept in favor of these new factory methods. |
Can you provide a code snippet here that demonstrates what you want? I'm thinking something like |
I was thinking.... class RequestFactory {
public function __construct(BodyFactory $bodyFactory);
// returns \Slim\Http\Request
public function build($attributes, $headers);
}
$request = $requestFactory->build($_SERVER, $headers); The reason behind it, so we have more control of the Body Object and how it's created. The Request shouldn't know or care how the Body is created, or URI object. |
👍 Will get started today. |
@geggleto Couldn't the same be said for headers and uri? |
I'm not entirely sold on the need for separate factory classes... a class can know how to make itself, so why not |
I'm just worried about over-engineering for engineering's sake. |
For me it's abut reducing the class complexity. Factories are clean and easy to read. For someonek like me who does read the slim source it is nice to have readable code. I would say choose whatever is readable and testable. Decoupling away from the use of globals inside methods and surfacing them to the signatures is the ultimate goal. /cc @codeguy |
Cool. I've started toying with an abstract factory. I've added the |
PHP 7 <3. I like the abstract factory pattern and this is looking quite good. |
https://gist.github.com/geggleto/37539ebbd679f28995b4 Been toying around with moving the construction logic. I really want to rename the Environment class as its a container around _SERVER. |
I think we should rename the Request class, as in PSR 7 there are differences between ServerRequest and just Request. Slim internally uses ServerRequestInterface, so it would probably be best to reflect that. |
Dropping this in here, https://github.com/geggleto/slim-http Lot's of refactoring, and renaming. |
If we support factories, then https://github.com/http-interop/http-factory is the way to do it. |
I would love to see proper Factories.
Will PR @akrabat ;)
The text was updated successfully, but these errors were encountered: