in my application i have a route (Literal or segment) for every action. i am not using one global route for everything so as a result the number of routes has grown hugely with 44+ modules (and more in future) .
It is my understanding (from what i have seen in the code) that in every page request zend goes throw all this routes in a array ans searches for a match witch could be bottleneck for the application (am i right?)
So i was thinking why not cache the matched routes in a db table with index to speed up the search ?
FIRST QUESTION : would this make the systems performance better?
so my first problem is skipping the system route matching mechanism. this is what i tried but it did not work :
public function onBootstrap(MvcEvent $e)
{
$em = StaticEventManager::getInstance();
$em->attach('Zend\Mvc\Application', MvcEvent::EVENT_ROUTE, array($this, 'onRoute'), 100);
}
public function onRoute(MvcEvent $e)
{
//var_dump($e->getRouteMatch());//->null routing has not been done yet
/* @var $router \Zend\Mvc\Router\Http\TreeRouteStack */
$router = $e->getRouter();
//-------------------------------------created a dummy route
$routeMatch = new \Zend\Mvc\Router\RouteMatch(array(
'controller' => 'Links\Controller\Items',
'action' => 'view',
'catId' => 0
));
$routeMatch->setMatchedRouteName('app/links');
$e->setRouteMatch($routeMatch);//set the dummy route
//--------------------------------------------PROBLEM HERE
//detach the onRoute event from routeListener
$e->getApplication()
->getServiceManager()
->get('RouteListener')
->detach($e->getApplication()->getEventManager());
}
the detach method is executed but the onRoute event still gets executed and matches the url to the correct route. so how to bypass(skip|detach) route matching ?