A. Martyn A. Martyn - 1 year ago 178
PHP Question

Get master request in Symfony 2.4

When rendering another controller from the view, master request gets lost - this means that, for example, GET parameters will not be available in that rendered (included) controller.

What is the way to access the query string in rendered controllers, except accessing $_GET directly (this works).

I've found some legacy code in the project which does the thing, but it's deprecated in 2.4 and will be removed in 3.0 already:


Here $this->container is the ContainerInterface.

Answer Source


From the RequestStack you can get the master request $stack->getMasterRequest().

The request as a service is deprecated $this->container->get('request'), but this stack replaced it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download