Prev | Current Page 689 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"


Creating the Front-End Controller
To begin, create a file named index.php and place the code found in Listing 24-1
inside it. The index.php script is known as the front-end controller and, believe it or
not, will be responsible for ensuring that every request for this application receives
the appropriate response. This document should reside in your desired application
document root.
Additionally, in the same directory create a directory named application, and in
that directory create a modules directory, and within that create a default directory.
Finally, within the default directory create two more directories named controllers
and views, and within the views directory create a directory named scripts, each of
which you??™ll use later.
Listing 24-1. The Application??™s Front-End Controller (index.php)
// Load the Front Controller class
require_once('Zend/Controller/Front.php');
CHAPTER 24 ?–  MVC AND THE Z END F RAMEWORK 613
// Instantiate an instance of the Front Controller Class
$frontController = Zend_Controller_Front::getInstance();
// Point to the module directory
$frontController->addModuleDirectory('./application/modules');
// Throw exceptions (useful during debugging)
$frontController->throwExceptions(true);
// Start the Front Controller
$frontController->dispatch();
?>
It is assumed the Zend Framework application will reside in the server??™s document
root.


Pages:
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701