ZF-5679: Zend_Controller_Router_Route_Hostname - parameters doesn`t persist

Issue Type: Bug Created: 2009-02-03T07:50:20.000+0000 Last Updated: 2011-11-08T19:02:47.000+0000 Status: Open Fix version(s): Reporter: Gonzalo Benitez (gonzalobenitez) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Controller

  • zf-crteam-padraic
  • zf-crteam-priority

Related issues: Attachments:


I find a problem while i was trying to use Zend_Controller_Router_Route_Hostname with a Language plugin, using the route to put the parameter ";language" into a subdomain.

  • Route via Zend_Config

routes.language_default.type = "Zend_Controller_Router_Route_Hostname" routes.language_default.route = ":language.localhost" routes.language_default.defaults.module = "public" routes.language_default.defaults.controller = "index" routes.language_default.defaults.action = "index" routes.language_default.defaults.language = "www" routes.language_default.reqs.language = "(?!www$).*"

when i type;


seems not to be problems, but if i uso an other router like:

  • Route via Zend_Config = "Zend_Controller_Router_Route_Static" = "contact" = "public" = "contact" = "index"


the parameter of the subdomain persist in the url, but when i try to request the language from my language plugin didn`t return anything;

  • In the language plugin:

if (!$language = $request->getParam('language', false)) { $language = $locale->getLanguage(); }

it`s returning a (1) false parameter.


Posted by Ben Scholzen (dasprid) on 2009-02-18T08:40:09.000+0000

I could be wrong, but could it be, that you simply didn't chain the static route with the hostname route (as the example shows in the manual)?

Posted by Gonzalo Benitez (gonzalobenitez) on 2009-02-19T05:56:14.000+0000

Hi Ben yes i though it could be... but.. i tryed by an other way because i could not make it chain via config.ini..

$languageRoute = new Zend_Controller_Router_Route_Hostname( ':language.localhost', array( 'module' => 'public' ) );

    $defaultroute = new Zend_Controller_Router_Route_Static(
            'controller' => 'index', 
            'action' => 'index'
    $router->addRoute('default', $languageRoute->chain($defaultroute));

           $contactroute = new Zend_Controller_Router_Route_Static(
            'controller' => 'contact', 
            'action' => 'index'
    $router->addRoute('contact', $languageRoute->chain($contactroute));

ass you can see, it is chained, but there is still a problem, i don`t know if this is the way it is spected to work.. but to make it work i needed to add this lines to my language plugin

    $router = Zend_Registry::get('router');
    $router->setGlobalParam('language', $language);

    Zend_Registry::set('router', $router);

i think could be better if the hostname parameters persist as a global parameter throw the chained routes, what you think about it?

Posted by Ben Scholzen (dasprid) on 2009-05-09T08:23:38.000+0000

I don't see this as an issue, as every chained route exists for it alone, at least at the moment. Tho that will change with the refactoring for 2.0.

Posted by Adam Lundrigan (adamlundrigan) on 2011-11-08T19:02:47.000+0000

Is this still an issue? If so, can you provide some additional information on your language plugin? The language parameter from the hostname route will only be passed along to routes which are chained to it, and can then be retrieved through the router object's getParam method. Without seeing how you're trying to access that parameter through your language plugin we can't help.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.