Each controller to be used with the framework (i.e. render views, links to functions etc) must extend Controller class:

class MyAwesomeController extends Controller {

Each controller inherits a whole range of useful and needed features


Should always be used when linking within the framework, because absolute links are needed by the routing and always checks against your custom routes.

//without custom routes
// returns http://localhost/PHP_PLAIN/index.php/MyAwsomeController/moreAwsomerFunction

From time to time, you need to pass some dynamic values to your controllers, e.g. an ID to display specific content. Therefore you can pass an array or lined up values to your controller function. These values occur as parameter in the same order as given to to linkTo function.

Users::linkTo("show", 3 );
// returns http://localhost/PHP_PLAIN/index.php/Users/show/3

//Users controller
public static function show($userId){
    // $userId = 3

Note: It is possible to line up as many parameters as you like.

For more informations, please visit the routing section


Is just the same usage like the linkTo function.

After a redirect no other code is interpret.

public static function login(){
    //a lot of validation
        MyAwesomeController::redirectTo("superSecretWebsite", 333);
    //error - back to frontpage
    //unreachable code
    echo "yay";


The render method looks up the appropriate view and renders it on the index.php (in the yield())

Please find details in render views


The renderPartial method searches the associated view and renders it to the point where the call took place.

Please find details in render views


With extendFromTemplate we can tell our render call to extend the corresponding view in the given template.

Please find details in the templates section


renderText does not render in the _yield() function, but prints the text with the correct Content-Type header (text / plain) set, and ends the script processing.

public static function debugMe(){
    self::renderText("plain text here");
    //unreachable code
    $var = "im completely useless";


renderJSON works similarly to renderText, but expects an array. The data will output as a json_encoded string with the Content-Type header is set to application / json. The script processing is suspended here.

public static function someJSONResponse(){
    	"ok" => true


The always function runs at the latest before each render call. So you can add stylesheets or scripts, extend all render calls from a template oe secure the whole controller with validations.

public static function always(){

Usually (in most other frameworks), this function is called as before(), as it simply is not true depending on the execution order, I was looking here for a new name.


There are always JavaScripts that can be used only on a single, or only a few pages. In order for this not to be loaded on every page request, you can load the required scripts in the corresponding controller function

public static function controllers(){


Has the same functionality as addScript, only for stylesheets

Also available in the above example


The isActive function tries to find out (based on the URL and the renderArgs) if the calling controller is the currently active.

As an optional parameter, the view (or function) cann be passed, so the \"active\" result is additionally limited to the view

A recent example: on the current page, the side menu is only displayed when you are in the Manual Controller.

    //render side menu
//for active state in menu
if(Manual::isActive("controllers")) echo "style='color: blue;'";

keep & get

The keep function stores key - value pairs in a private session cookie, and kept as long until they brought back with the get() function.

public static function auth(){
    //authorization failed, store error in temp cookie
    self::keep("error", "failed to login for some reason");

public static function login(){
    //if nothing is set, get() returns false 
    //so every error disappers after a reload 
    //(see login example in the default download)
        "error" => self::get("error")

add & setRenderContent

With addRenderContent(key, val) you can add dynamic parts before the render() call, e.g. to set in a view a subtitle (or with setTitle the title tag in the index.php)

With getRenderContent(key) the content can be loaded in the view.

Difference to keep & get: renderContent is temporarily stored by the controller and issued with a render() call, and not stored in a cookie, so it can not be seen from outside, but also not valid for a request away.

    // App::index 
    App::addRenderContent("subtitle", "PLAIN_PHP is really simple, fast and i enjoy coding with it");
    // some view
    <?php echo Controller::getRenderContent("subtitle"); ?>

get & setTitle

setTitle is a shortcut for addRenderContent('title', your title) to fill the title tag.

    //in Manual controller 
    self::setTitle("PLAIN_PHP - Manual");
    //in the dafault index.php file
    <title><?php echo Controller::getTitle(); ?></title>