Scott Scott - 2 months ago 15x
PHP Question

ZF2 - Get current URL in Controller

This seems like it should be a simple task. I need the current URL from a function within the Controller. This function can be called from multiple actions, and the end goal is to set a form's action attribute. (Side note: It appears IE does not send an ajax request if the URL starts with '#').

I feel like my google-fu is off today because I could not find a good way to do this Zend Framework 2. I have this line currently, but it feels very bulky:



Couldn't you just get the URI from the request object:


Provided your controller extends Zend\Mvc\Controller\AbstractActionController.

Note: This would output the entire URL, like so: