ZF routing task

I just started my adventure with zend framework 1.9.1, but I ran into several problems. I would like to remove the default routes in order to avoid displaying the same content on different URLs - in order to achieve it, I wrote a custom function in bootstraper

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initMyRouter()
    {
        $this->bootstrap('router')
             ->getContainer()
             ->frontcontroller
             ->getRouter()
             ->removeDefaultRoutes();
    }
}

but after that, one problem arises - each invalid URL reaches the default controller instead of the error controller. To solve this problem, I set resources.frontController.defaultcontrollername = "error" resources.frontController.defaultaction = "throw" in application.ini and

public function throwAction()
{
    throw new Zend_Controller_Dispatcher_Exception;
}

in ErrorController to work around this, but my question is ... am I doing something wrong?

, URL-, resources.frontController.baseurl = " http://mydomain.com/" application.ini, URL . ?

( )... Zend_Controller_Action_Helper_Url:: url ? - $this β†’ _ helper- > url (array(), 'frontpage'), Zend_Controller_Action_Helper_Url:: direct

+3
1

, , .

$this->view->url(array(...), 'routeName', true);, . , / , . , $this->_helper->url->url(...) - .

, , , .

+1

Source: https://habr.com/ru/post/1715104/


All Articles