Archive for the ‘Others’ Category

My first step to Zend Framework

Good Day !!!

I am just keeping my leg in to Zend Framework.

Extending the art & spirit of PHP, Zend Framework is based on simplicity, object-oriented best practices, corporate friendly licensing, and a rigorously tested agile codebase.

At the first step I faced several problems. Mainly the one was

Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in C:\wamp\library\Zend\Controller\Dispatcher\Standard.php:241 Stack trace: #0 C:\wamp\library\Zend\Controller\Front.php(934):
 Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), 
Object(Zend_Controller_Response_Http)) #1 C:\wamp\www\test\zendTest3\html\index.php(6): Zend_Controller_Front->dispatch() #2 {main} thrown in C:\wamp\library\Zend\Controller\Dispatcher\Standard.php on line 241

This is what made me fedup on earlier step.

But with my trustful effort I managed to find out the reason why I am getting this error. It was mainly because of Path. The path to controllers directory. I guess it is because of the OS what I was using is Windows. Linux users might not get this problem. To overcome this problem, it is best practice to specify the path by calling current directory using the script as follows.

<?php
 
defined('APPLICATION_PATH')
or define('APPLICATION_PATH', dirname(__FILE__));
$frontController = Zend_Controller_Front::getInstance();
$frontController->setControllerDirectory(APPLICATION_PATH.'/controllers');

This is the best coding practice given by Zend. :) Never forget the standards.