Home > Zend Framework > Zend Framework URL helper

Zend Framework URL helper

There are two URL helpers in the Zend Framework that help generate URLs from action and controller names:

  1. Action helper: This has the signature url($action, $controller = null, $module = null, array $params = null)
  2. 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 :-) )

  1. No comments yet.
  1. No trackbacks yet.