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

  • Home
  • SEARCH
  • 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 8883519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:49:53+00:00 2026-06-14T20:49:53+00:00

I’m using Zend framework 1.12, trying to come up with custom routes. I’m trying

  • 0

I’m using Zend framework 1.12, trying to come up with custom routes.

I’m trying to create something that looks like facebook’s profile URL (http://facebook.com/username). So, at first I tried something like that:

$router->addRoute(
            'eventName',
            new Zend_Controller_Router_Route(
                '/:eventName', 
                array(
                    'module' => 'default', 
                    'controller' => 'event', 
                    'action' => 'detail'
                )
            )
        );

I kept getting the following error anytime I tried running mydomain.com/something:

Fatal error: Uncaught exception ‘Zend_Controller_Router_Exception’
with message ‘eventName is not specified’ in
/var/desenvolvimento/padroes/zf/ZendFramework-1.12.0/library/Zend/Controller/Plugin/Broker.php
on line 336

Not only I was unable to make that piece of code work, all my default routes were (obviously) overwritten. So I have, for example, stuff like “mydomain.com/admin” that should send me to the “admin” module, on the Index controller, but was now returning the same error (as it fell in the same pattern as /:eventName).

What I need to do is to create this custom route, without overwriting the default ones and actually working (dûh).

I have already checked the online docs and a lot (A LOT) of stuff on google, but I didn’t find anything related to the error I’m getting or how to not overwrite the default routes. I’d appreciate anything that could point me the right direction.

Thanks.


EDIT¹:
I managed to get it working, but I didn’t use any routing at all. I just made a plugin with the following:

public function preDispatch(\Zend_Controller_Request_Abstract $request) {

    if (!\Zend_Controller_Front::getInstance()->getDispatcher()->isDispatchable($request)) {

        $request->setModuleName($this->_eventRouter["module"]);
        $request->setControllerName($this->_eventRouter["controller"]);
        $request->setActionName($this->_eventRouter["action"]);

    }

}

It feels like an ugly workaround, though… As Tim Fountain pointed out, my events are dynamic (I load them from a database), so I can’t hardcode it. Also, my current implementation prevents me from having to hardcode every module/controller/action combination.

I’d just like to know if there’s a way to avoid using a plugin.


EDIT²: I’m not doing that crappy plugin thing anymore. I figured out what was causing the router error. My routing definition did not have a valid default value for variable ‘eventName’. My fix was:

$router->addRoute(
        'eventName',
        new Zend_Controller_Router_Route(
            '/:eventName', 
            array(
                'module' => 'default', 
                'controller' => 'event', 
                'action' => 'detail',
                'eventName' => ''
            )
        )
    );

I am still unable to create routes with “conflicting” patterns, such as /admin and /:eventName. If only there was a way to make /admin override /:eventName…

  • 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-14T20:49:55+00:00Added an answer on June 14, 2026 at 8:49 pm

    Routes are applied/matched on a LIFO basis. As the routing docs note:

    Note: Reverse Matching
    Routes are matched in reverse order so make sure your most generic routes are defined first.

    So, in order to have your “static” routes (static, in the sense that they do not pull from the db, /admin and the like) apply over your dynamic ones (/:eventName), make sure you define the static ones later in the execution flow.

    In practical terms, this means that you cannot define your static routes during bootstrap, so you’ll have to do it in a plugin with a routeStartup hook. Perhaps, two plugins: one for your dynamic routes, then another for the static ones, just make sure that the priority on the plugins is set so that the static ones are added later.

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.