webCOMAND

controller::__construct()

A controller is not typically instantiated directly, like in the example below.  Instead, if a router matches a portion of the request URL to the filename of a file in the controllers/ folder, it will instantiate the controller and attempt to match the subsequent portion of the request URL to the name of the controllers public methods.  If no subsequent portion of the URL is defined, the router will look for a public method named web__index().  If no matching method is found, the router will return or respond with a 404 Not Found error.

Prototype

controller __construct(array $options)

Parameters

  • options - Associative array with the following keys.
    • ajax - The ajax object to use to access the web request and produce the response, if this is an AJAX request.
    • request - The request object to use to access web request, GET/POST parameters, etc.
    • router (REQUIRED) - The router used to access config and view files.  This is the only required key/value pair and an exception will be thrown if it is not provided.

Example

$router = new \io_comand_mvc\router();
$controller = new \io_comand_mvc\controller(['router'=>$router]);
$controller->show_error('Invalid request');