System files for DispatchPHP.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


DispatchPHP System Files

DispatchPHP is a simple set of conventions for organizing PHP applications enforced with a small bit of code.

Set Up

These system files are designed to be run in the system directory from the root directory of your application. The reason for this is to make it easy to track the system files via git submodules. Therefor, to install these system files into your project, you would simply run the following commands from your project's top-level directory:

git submodule add git:// system
git submodule init
git submodule update

Next, you'll want some how redirect all of the web request through the system files. One way to do that is with an .htaccess file in your application's root directory that looks similar to this:

RewriteEngine On
RewriteBase /

# Don't let people access our files
RewriteRule ^(application|system) - [F,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]

Then, you'll want an index.php in the root directory of your application. Something similar to this:


// Define some global constants to make including easier
define('ROOT',             dirname(__FILE__) . '/');
define('APPLICATION_PATH', ROOT . 'application/');
define('CONFIG_PATH',      ROOT . 'config/');
define('SYSTEM_PATH',      ROOT . 'system/');

// Define the autoloader strategy
require(SYSTEM_PATH . 'autoloader.php');

// Dispatch the request for the give URL

That's it for set up.