Boostrap

Introduction

The boostrap is what configures the application and starts it. A typical boostrap will create a Locator, populate it with Request and Response object, configure the Front Controller, and run it.

Here is an example bootstrap:

<?php

require '/path/to/lib/A/Locator.php';

// create registry and initialize autoloading
$Locator = new A_Locator();
$Locator->autoload();

// populate the Locator with the necessary objects
$Locator->set('Request', new A_Http_Request());
$Locator->set('Response', new A_Http_Response());

// tell the framework where to find application files (controllers, views, models, etc.)
$Mapper = new A_Controller_Mapper('/path/to/app/', array('', 'home', ''));

// create and run the front controller
$Controller = new A_Controller_Front($Mapper, array('', 'error', ''));
$Controller->run($Locator);

// provide final output from view
echo $Response->render();

Normally, your application should only have to include one file: the Locator. After autoloading has been initialized, all files are loaded manually.

The Locator is the most integral part of Skeleton Framework. It is passed throughout the application, and contains important objects that need to be shared. More info on it's documentation page.

The Request object represents the HTTP request made to run this application. It contains things such as GET and POST data, the protocol used, access to cookies, et cetera. Request is need by the Front Controller, and used by application controllers.

About mapper?

Front Controller is responsible for routing the HTTP request to the appropriate action controller. It uses data in the Request object (inside the Locator) to find out what action to run. The default is to use the module, controller, and action GET parameters, but this is settable. Pathinfo allows a more versitile routing system.

The last step in most applications is to output the Response. This can be done simply by echoing the returned value of render().