Creating Controller

Zend Framework Step By Step Tutorial - Part 5: The front controller pattern maps the URL requested by the user to a particular member function within a specific controller class. We called as routing and dispatching. The controller class have a strict naming convention requirement. The router calls a function named {actionname}Action() within the {ControllerName}Controller class. This class must be within a file called {ControllerName}.php. If not provide, index will be used. Still confuse? look at this example:
Create a file named "IndexController.php" within application/controllers.
Enter following code:
<?php
require_once 'Zend/Controller/Action.php';
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$this->view->assign('title', 'Hello, World!');
}
} ?>
Within the front controller system, the dispatcher expects to find a file called IndexController.php within the application/controllers directory. This file must contain a class called Indexcontroller and, as a minimum, contain a function called indexAction().

0 comments: