How to get zend framework 2 base path with domain name in layout ?

March 5, 2013

There is a easy way to get zend framework 2 base path with domain name in layout.

1. In layout.phtml

$homeUrl = $this->url('home',array(),array('force_canonical' => true));

2.Adding home route in module.config.php

'home' => array(
    'type'    => 'Zend\Mvc\Router\Http\Literal',
    'options' => array(
        'route' => '/',
        'defaults' => array(
            'controller' => 'Application\Controller\Index',
            'action'     => 'index',
        ),
    ),
),

Simple as that.

tags: , , ,
posted in how to ?, Zend Framework 2 by Ivan Gospodinow

Follow comments via the RSS Feed | Leave a comment | Trackback URL

2 Comments to "How to get zend framework 2 base path with domain name in layout ?"

  1. adam wrote:

    Man thanks for that! I was about to dig into Url helper/plugin class to look it up but found it first here.

  2. Tong Uyen wrote:

    Thank you very much.

Leave Your Comment


Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /home/c2kblate/sites/ivangospodinow.com/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048
 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org