Zend Framework URL helper
There are two URL helpers in the Zend Framework that help generate URLs from action and controller names:
- Action helper: This has the signature url($action, $controller = null, $module = null, array $params = null)
- View Helper: Signature url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
While using the Action helper, use the following code:
$url = $this->_helper->url(‘auth’,'login’);
Note that the controller and action are strings.
and, when using the View Helper function,
$url = $this->view->url(array(‘controller’=>’auth’,’action’=>’login’));
It is easy to mix up the syntax (And, if you do mixup, you will get an additional “/Array” at the end of the url .. voice of experience
)
Categories: Zend Framework
/Array, URL Helper, Zend Framework