Table of Contents

Page lifecycle

Oxwall is under developement at the moment, so below you can see only preliminary version of page-lifecycle. Oxwall implements front-controller pattern and all requests are handled by single script - index.php (it is the only script available for user requests). Lets see how it works:

First of all .htaccess file in root directory helps us to redirect all requests to front-controller script.

Code of .htaccess:

Options +FollowSymLinks
RewriteEngine On
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php

Below you can see the code of index.php script:

Code of index.php:

define('_OW_', true);
 
define('DS', DIRECTORY_SEPARATOR);
 
define('OW_DIR_ROOT', dirname(__FILE__).DS );
 
require_once(OW_DIR_ROOT.'includes'.DS.'init.php');
 
$application = OW_Application::getInstance();
 
$application->triggerEvent(OW_EventManager::APPLICATION_INIT);
 
$application->triggerEvent(OW_EventManager::ROUTE_STARTUP);
 
$application->route();
 
$application->triggerEvent(OW_EventManager::ROUTE_SHUTDOWN);
 
$application->dispatch();
 
$application->finalize();
 
$application->returnResponse();

As we can see index.php is very simple script representing a number of definite logic steps:

 <-- Page start -->

Define 3 basic constants

Include init.php script (loads modules for application startup)

Create an instance of front-controller class (OW_Application) and initialize it

Trigger event APPLICATION_INIT

 <-- User request handling start -->

Route requested uri (Routing process)

 <-- If matches were not found -> show 404 page -->

Trigger event ROUTE_SHUTDOWN

Dispatch routing results (dispatching process)

Trigger event FINALIZE

Compile and send response

 <-- Page end (Here script dies) -->