Search code examples
phpzend-frameworkzend-route

Full url with schema, domain and port


How do assemble (using Zend Routes) the full url with schema, domain and port, not just a root-based path?

Sample use case: we need to specify full url in the emails sent to the clients.

AFAIK there is no any built-in solution but what is a best practice in this case and/or what do you specifically use in such cases?


Solution

  • Use a combination of ServerUrl and Url view helpers, eg

    <a href="<?php echo $this->serverUrl($this->url(array(
        'url' => 'params'), 'route', $reset, $encode)) ?>">My Link</a>