In my view I need to draw full URL. Like this:
http://hostename.com/default/url
When I try to use $this->url('default', array(1,2,3))
I get only /index/get/
. Is there any Zend method to het host name or I have to use $_SERVER['HTTP_HOST']
instead?
You can use the option
force_canonical
on the router. All router options go into the third parameter of the url helper:So you can so something like this:
There is a Zend\View\Helper\ServerUrl to create full url in zend view. Try below code in your view template.
If you want to set base URL globally, you can do it using onBootstrap method:
In this case Navigation helpers would also use it.
To fetch current base URL use ServerUrl helper as described in this thread:
I found this article with some interesting ways:
1) without parameters use an empty array:
2) note the differences between:
and
3) starting from the route