2.1 Application Singleton - marcos-c/sketch-php GitHub Wiki
SketchApplication
class inlibrary/Sketch/Application.php
Sketch bootstraps initialization into an application singleton. The application singleton provides easy to use accessors to the running context, HTTP request, HTTP response, session, logging and localization services.
A default bootstrap is provided in library/Sketch/Stub.php
.
if (!defined('APPLICATION_PATH')) {
define('APPLICATION_PATH', realpath(dirname(__FILE__)));
set_include_path(
APPLICATION_PATH.'/library'.PATH_SEPARATOR.get_include_path()
);
}
require_once 'Sketch/Stub.php';
This bootstrap sets the default Content-Type to text/html; charset=UTF-8
.
The PHP error handler to array('SketchApplication', 'exceptionErrorHandler')
.
And the document root to APPLICATION_PATH
.
The running context configuration is loaded from APPLICATION_PATH.'/config/context.xml'
.
Then, the bootstrap takes care of the HTTP request and session instances, and the logging and localization services.
And last, the HTTP response is created and returned to the client.
Take notice that this is only the default bootstrap. You are encouraged to create your own bootstrap. Using the application singleton, extending it or even replacing it with your own implementation.