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

Build request object within dispatcher if not already defined in container #26

Closed
ryanhalliday opened this issue Feb 24, 2015 · 4 comments

Comments

@ryanhalliday
Copy link

In RequestResponseStrategy.php, when Symfony\Component\HttpFoundation\Request is fetched from the League Container, if it is not already set in the container then it will initiate a largely useless Request object that contains none of the globals that HttpFoundation Request is normally initiated with.

I am not extremely familiar with Dependency Injection so I don't know what the ideal fix for this is in this package. When using Route in a project you can make a Service Provider for HttpFoundation or set it with $container->add('Symfony\Component\HttpFoundation\Request', Request::createFromGlobals());, but it was quite unexpected to have to do so.

@philipobenito
Copy link
Member

This is something I've been thinking about recently and I think you're right, we should probably build the request object within the dispatcher if it has not already been defined.

@philipobenito philipobenito changed the title Defaults for HttpFoundation Request Build request object within dispatcher if not already defined in container Feb 24, 2015
@hannesvdvreken
Copy link
Contributor

@ry167 I would wrap that in a closure:

$container->add('Symfony\Component\HttpFoundation\Request', function () {
    return Request::createFromGlobals();
});

@philipobenito
Copy link
Member

Apologies for the delay in addressing this, for v1 I will be implementing a check for the whether the request has been instantiated properly or not and then building it if not. v2 wll handle it slightly differently as there is a change around the HTTP layer of dependencies.

@philipobenito
Copy link
Member

Fixed by 803cad3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants