-
Notifications
You must be signed in to change notification settings - Fork 0
Controller
LaCodon edited this page Dec 15, 2015
·
2 revisions
- Controller Template
- Save paths and naming conventions
- "404 Not found" Controller
- Famework_Controller class
Every Controller has to directly or indirectly extend Famework\Controller\Famework_Controller
and implement a init()
method.
<?php
use Famework\Controller\Famework_Controller;
class IndexController extends Famework_Controller {
public function init() {
$this->_paramHandler = new Paramhandler();
}
// put actions here
}
Every Controller script has to be named accoring to the following rules:
- First letter uppercase + some lower case chars + "Controller.php"
e.g.:IndexController.php
orLoginController.php
- The class name has to be equals to the filename
e.g.:IndexController
orLoginController
It is possible to save the Controller script wherever you want but keep in mind that every controller has to be required or autoloaded somewhere in your project. The best place to do this is your /index.php
Actually, a default 404 page is automatically rendered if a Controller or Action was not found but it is possible to customize this default page within the IndexController
. Just insert this method:
...
class IndexController extends Famework_Controller {
...
public function notfoundAction() {
$this->_view->turnLayoutOff();
}
...
}
See Famework_View for more information about turnLayoutOff()
.
{abstract}
# $_view: Famework_View
+ init(): void
- Home
- Getting Started
- Server Setup
- Configuration Files
- Application Structure
- Classes