Controllers are the driving force of a PIP application and are stored in the "app/controller" directory.

RESTful Routing

PIP uses search-engine and human friendly URLs, and automatically routes to the required controller using a segment-based approach:

Pip adds a suffix of Controller to the controller classname, and it prefixes the action with get or post, depending on the type of request.

So the following Url:

would route to class AlbumController (in file app/controllers/album.php) and call the function getShow with a parameter value of 65.


class AlbumController extends Controller {

    function getIndex()
        // This is the default function (ie. no function in the URL)
    function getShow( $param )
        // show album with id = param (65) 


Note that if you need to declare a contructor you must also call the parent constructor like:


class ExampleController extends Controller {

    public function __construct()
        // Your own constructor code


There are several helper functions that can also be used in controllers. Most of these functions take the parameter $name of the corresponding class:

Note: Also see the configuration file config['register'] option to pre-load models, helpers, etc.

    loadModel($name);       // Load a model
    loadView($name);        // Load a view
    loadPlugin($name);      // Load a plugin
    loadHelper($name);      // Load a helper


The redirect function has been added to helpers/Url. The original controller function redirect($location) (redirect to a page without having to include the base URL) has been retained for backward compatibily.