Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8120759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:15:13+00:00 2026-06-06T05:15:13+00:00

Zend Project with multiple modules and every modules have its own routes.ini defined inside

  • 0

Zend Project with multiple modules and every modules have its own routes.ini defined inside it. and every routes.ini file is being loaded using following script in module based bootstrap files.

 protected function _initRoutes() {
            $frontController = Zend_Controller_Front::getInstance();
            $router = $frontController->getRouter();
            $routerDir = realpath(dirname(__FILE__)). "/configs/routes/moduleRoutes.ini";
            $config = new Zend_Config_Ini($routerDir,'production');
            $router->addConfig($config,'routes');
    }

and All routes are being loaded without order. because Routes are checked in reverse order of loaded sequence and it check/execute those routes first which it should check/execute later.

Is there a way that I can add a orderBy bit (1,2,3,4…) with every route in routes.ini file of each module and load them in specific order so that It will check the routes in sequence I define.

typical routes.ini file of modules looks like this.

routes.frontindex.type = "Zend_Controller_Router_Route_Regex"
routes.frontindex.route = "/?(?!login/)([a-zA-Z0-9_-]+)?/?([a-zA-Z0-9_-]+)?/?([0-9_-]+)?"
routes.frontindex.defaults.module = mymodule1
routes.frontindex.defaults.controller = mycontroller1
routes.frontindex.map.page = 1

routes.siteimage.type = "Zend_Controller_Router_Route_Regex"
routes.siteimage.route = "siteimage/?([a-zA-Z0-9_-]+)?/?(jpg|png|gif)?"
routes.siteimage.defaults.module = mymodule1
routes.siteimage.defaults.controller = mycontroller2
routes.siteimage.defaults.action = getimage
routes.siteimage.map.imageid = 1


routes.sitemapseo.type = "Zend_Controller_Router_Route_Static"
routes.sitemapseo.route = "sitemap.xml"
routes.sitemapseo.defaults.module = mymodule1
routes.sitemapseo.defaults.controller = mycontroller3
routes.sitemapseo.defaults.action = sitemap
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:15:15+00:00Added an answer on June 6, 2026 at 5:15 am

    It can be done, but it will take some work and you’ll need to be fairly comfortable with ZF.

    You’ll need to extend Zend_Controller_Router_Rewrite to make your own router class (which you will need to set using the front controller’s setRouter() method in the bootstrap). In your router class, you’ll want to:

    • Extend the addRoute method to add a third parameter indicating priority. (This could be a constant like Your_Router::HIGH_PRIORITY, Your_Router::MEDIUM_PRIORITY etc. or simply a number). You’ll see that the existing method stores routes in an array called _routes. You could instead store routes in different array depending on the priority param ($this->_highPriorityRoutes, $this->_lowPriorityRoutes etc.)

    • Extend the route() method. Most of that unfortunately will be cut and paste. But you’ll see that it calls array_reverse on $this->_routes and then loops though these to do the matching. You’ll want to merge together your route arrays so that the end result is an array with your highest priority routes first. So you might end up with something like:

      $routes = array_merge($this->_lowPriorityRoutes, $this->_highPriorityRoutes);
      $routes = array_reverse($routes, true);
      
      foreach ($routes as $name => $route) {
          (...as before)
      
    • Update your ini files to add a parameter to your routes indicating the priority. Then extend the addConfig() method in the router class so it passes this parameter to the addRoute() method.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Zend Framework project on a local machine, and as recommended its
I have been using doctrine with zend in a project without modules. It is
I have project written in Zend Framework and it works fine most of environments.
Is it best to have each application with its own copy of the ZF
I have a zend framework project and use the ZendX_JQuery_View_Helper in my bootstrap to
In my Zend Framework project, I have a form that I am testing. In
I implemented a Zend project And its working fine Now i tried to implement
I have a requirement to implement audit logging functionality in a zend project. The
I typed this: http://localhost/dev.gamenomad.com/Index and I have got this controller in my zend project:
I have following structure in my Zend-Project : -application - PDF - configs -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.