Jump to content

Routing in Zend Framework


leela

Recommended Posts

 

Hi,

 

I am having the issue regarding ROUTER .I am able to route index but not other actions .. If i comment the route code for index , then in url

http://localhost/postblog/public/p/add can be able to go to add ..... why both index and add actions are not working at the same time..

we use 1.11 version

 

My Files

routes.ini

 

[production]

;routes.login.type = "Zend_Controller_Router_Route"

; ----------------- USER ROUTING -----------------
routes.post.route = "/p/:action/*"
routes.post.defaults.module = "Post"
routes.post.defaults.controller = "posts" 
routes.post.defaults.action="index"

routes.post.route = "/p/add"
routes.post.defaults.module = "Post"
routes.post.defaults.controller = "posts" 
routes.post.defaults.action = "add"

[staging : production]

[testing : production]

[development : production]

 

bootstrap.php

 

<?php


class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

public function init() {
        
        //Start session
    }    

protected function _initDoctype()
{
$this->bootstrap('view');
$view=$this->getResource('view');
$view->doctype('XHTML1_STRICT');

}

protected function _initAutoload()
{
	$aModules = array(
	'Post'		 
	);

	foreach ($aModules as $module) {

		$loader = new Zend_Application_Module_Autoloader(
				array(
				       'namespace' => $module,
				       'basePath'  => APPLICATION_PATH . '/modules/'.$module,
				     ));

		$loader->addResourceType('form', 'forms', 'Form')
		       ->addResourceType('controller', 'controllers', 'Controller')
		       ->addResourceType('model', 'models', 'Model')
		       ->addResourceType('dbtable', 'models/DbTable', 'Model_DbTable')
		       ;

	}

}

protected function _initRoutes()   {

/**
* Set Routing
*/
$routeConfig = new Zend_Config_Ini("../application/configs/routes.ini", APPLICATION_ENV);  //TODO: Get environment from Apache config or environment variable
$router = new Zend_Controller_Router_Rewrite();

Zend_Controller_Front::getInstance()->getRouter()->addConfig($routeConfig, 'routes');
}





/*protected function _initPlugins()
{
	$this->bootstrap('FrontController');
                $front = $this->getResource('FrontController');
        
	* 
	 * Register plugins
	 * The alternative way is that put plugin to /application/config/application.ini:
	 * resources.frontController.plugins.pluginName = "Plugin_Class"

	$front->registerPlugin(new Etg_Controller_Plugin_Init());

} */


}

?>

 

my Application.ini

 

[production]



phpSettings.display_startup_errors = 0

phpSettings.display_errors = 0

includePaths.library = APPLICATION_PATH "/../library"

bootstrap.path = APPLICATION_PATH "/Bootstrap.php"

bootstrap.class = "Bootstrap"

appnamespace = "Application"

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"

resources.frontController.params.displayExceptions = 0



resources.view[] =
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = root
resources.db.params.dbname = zendblog

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.modules[]=""
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

 

 

Thanks for ur help,

Leela

Link to comment
https://forums.phpfreaks.com/topic/246748-routing-in-zend-framework/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.