Creating custom routes in your zend framework application

One of my zend framework project need to define custom routs . I have google a lot then found a solution.

Here I share my solution.

You can define custom routes in zend framework in many ways. I create a ini file to do this.

First add those line to your Bootstrap file.

protected function _initRoutes() {
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$myRoutes = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production');
$router->addConfig($myRoutes, 'routes');

This will tell the system routing information from “routes.ini” file from application/configs.

Then you need a routes.ini file in application/configs. Now create a new file named routes.ini there.

Now say for example your domain is and you want the to be

put the line bellow in routes.ini file:

[production] = /live = index = index
[production] represents your development environment.
Now if you create a module and need your custom route you can write this way. Say if you have a module calleduser , controller index and action index. Then your route should be like this.
But you want to make the url like = /info = user = index = index

Enjoy and Happy Coding 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s