IMPRESS dotted_line CONTACT dotted_line search dotted_line Kontakt dotted_line sitemap dotted_line print
84 PHP-Resource users online

Switch to another languags Deutsch aktuelle Sprache Englisch

PHP Manual

The Yaf_Controller_Abstract class

(No version information available, might only be in SVN)


Yaf_Controller_Abstract is the heart of Yaf's system. MVC stands for Model-View-Controller and is a design pattern targeted at separating application logic from display logic.

Every custom controller shall inherit Yaf_Controller_Abstract.

You will find that you can not define __construct function for your custom controller, thus, Yaf_Controller_Abstract provides a magic method: Yaf_Controller_Abstract::init().

If you have defined a init() method in your custom controller, it will be called as long as the controller was instantiated.

Action may have arguments, when a request coming, if there are the same name variable in the request parameters(see Yaf_Request_Abstract::getParam()) after routed, Yaf will pass them to the action method(see Yaf_Action_Abstract::execute()).

Class synopsis

abstract Yaf_Controller_Abstract {
/* Properties */
public $actions ;
protected $_module ;
protected $_name ;
protected $_request ;
protected $_response ;
protected $_invoke_args ;
protected $_view ;
/* Methods */
final private void __clone ( void )
final private __construct ( void )
final protected void display ( string $tpl [, array $parameters ] )
final public void forward ( string $module [, string $controller [, string $action [, array $paramters ]]] )
final public void getInvokeArg ( string $name )
final public void getInvokeArgs ( void )
final public void getModuleName ( void )
final public void getRequest ( void )
final public void getResponse ( void )
final public void getView ( void )
final public void getViewpath ( void )
final public void initView ([ array $options ] )
final public void redirect ( string $url )
final protected void render ( string $tpl [, array $parameters ] )
final public void setViewpath ( string $view_directory )



You can also define a action method in a separate PHP script by using this property and Yaf_Action_Abstract.

Example #1 define action in a separate file

class IndexController extends Yaf_Controller_Abstract {
$actions = array(
/** now dummyAction is defined in a separate file */
"dummy" => "actions/Dummy_action.php",

/* action method may have arguments */
public indexAction($name$id) {
assert($name == $this->getRequest()->getParam("name"));
assert($id   == $this->_request->getParam("id"));

Example #2 Dummy_action.php

class DummyAction extends Yaf_Action_Abstract {
/* a action class shall define this method  as the entry point */
public execute() {


module name



the request object




view engine object

Table of Contents

Comments to the PHP manual
Write new comment


New Tutorial entries

Migration einer PHP 5 App auf PHP 7

Dieses PHP 7 Tutorial zeigt dir, wie du dein PHP5 Script auf PHP7 umstellst.

Berni | Category: PHP
PHP 7 Virtual Machine

Dieser Artikel zielt darauf ab, einen Überblick über die Zend Virtual Machine, wie es in PHP 7 gefunden wird.

Berni | Category: PHP
plotting masters - a professional guide - Teil II

Grafische Interpolation und Bestapproximation von numerischen Wertepaaren: Wir wollen Punkte auf einer Zeichenebene über verschiedene Verfahren miteinander verbinden.

EVAMasters | Category: PHP