How to start Modular Zend framework Reviewed by Momizat on . Application/config/application.ini [php] [production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 phpSettings.date.timezone = "Eu Application/config/application.ini [php] [production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 phpSettings.date.timezone = "Eu Rating: 0

How to start Modular Zend framework

Application/config/application.ini

 [production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.date.timezone = "Europe/London"
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace ="Application"

resources.frontController.baseUrl = "/owner/"
resources.frontController.controllerDirectory = APPLICATION_PATH "/modules/default/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

resources.frontController.params.displayExceptions = 0
resources.modules[] =
resources.db.adapter = PDO_MYSQL
resources.db.params.host =localhost
resources.db.params.username =XXXXXXXXXXXXXX
resources.db.params.password =XXXXXXXXXXXXX
resources.db.params.dbname =XXXXXXXXXXXXX

acl.roles.Guest = null
acl.roles.Member = Guest
acl.roles.Admin = Member

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view.doctype = "XHTML1_STRICT"

[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


<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	protected function _initDoctype() {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
        $view->keywords = '';
        $view->Metatitle = '';
        $view->description = '';
		
		$configSection = 'production';
        Zend_Registry::set('configSection',$configSection);
        $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini',$configSection);
        Zend_Registry::set('config', $config);
        $frontController = Zend_Controller_Front::getInstance();
        
		
		
    }
	public function _initview()
    {
        $view = new Zend_View($this->getOptions());
        Zend_Dojo::enableView($view);

	
return $view;
    }
}


	

?>



Structure of modular

Change structure of folder

Set path in Zend\Application\Module\Autoloader.php

$this->addResourceTypes(array(
            'dbtable' => array(
                'namespace' => 'Model_DbTable',
                //'path'      => 'models/DbTable',
				'path'      => 'db/DbTable',
            ),
            'mappers' => array(
                'namespace' => 'Model_Mapper',
                'path'      => 'models/mappers',
            ),
            'form'    => array(
                'namespace' => 'Form',
                'path'      => 'forms',
            ),
            'model'   => array(
                'namespace' => 'Model',
                'path'      => 'models',
            ),
            'plugin'  => array(
                'namespace' => 'Plugin',
                'path'      => 'plugins',
            ),
            'service' => array(
                'namespace' => 'Service',
                'path'      => 'services',
            ),
            'viewhelper' => array(
                'namespace' => 'View_Helper',
                'path'      => 'views/helpers',
            ),
            'viewfilter' => array(
                'namespace' => 'View_Filter',
                'path'      => 'views/filters',
            ),
        ));
        $this->setDefaultResourceType('model');

And other path set in Zend\Controller\Action\Helper\ViewRenderer.php

 protected $_viewBasePathSpec = ':moduleDir/views';

    /**
     * View script path specification string
     * @var string
     */
    protected $_viewScriptPathSpec = ':controller/:action.:suffix';

    /**
     * View script path specification string, minus controller segment
     * @var string
     */
    protected $_viewScriptPathNoControllerSpec = ':action.:suffix';

    /**
     * View script suffix
     * @var string
     */
    protected $_viewSuffix      = 'phtml';

Change default controller and rewrite url in appliction/Bootstrap.php

public function _initview()
{
	$view = new Zend_View($this->getOptions());
	Zend_Dojo::enableView($view);
	
	$ctrl  = Zend_Controller_Front::getInstance();
	$router = $ctrl->getRouter();		
	$route = new Zend_Controller_Router_Route('manish/:action',array('module'=>'default','controller' => 'index','action'=> 'contactus'));
	$router->addRoute('manish1', $route);
	$route = new Zend_Controller_Router_Route('contact-us-abc/:action-:id',array('module'=>'default','controller' => 'index','action'=> 'contactus'), array('id' => '\d+'));
	$router->addRoute('manish', $route);
	$route = new Zend_Controller_Router_Route(':module-:controller/:id',array('module'=>'default','controller' => 'index','action'=> 'contactus'), array('id' => '\d+'));
	$router->addRoute('manish2', $route);


	return $view;
}

Leave a Comment

© 2014 Powered By