Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
System files for DispatchPHP.
PHP
tree: e7e3952358

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.markdown
autoloader.php
controller.php
dispatcher.php
view.php

README.markdown

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://github.com/jeremyboles/dispatch-system.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:

<?php 

// Define some global constants to make including easier
define('ROOT',             realpath(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');
spl_autoload_register('Autoloader::load');

// Include the routes
require(CONFIG_PATH . '/routes.php');

// Include the site-wide helpers
require(APPLICATION_PATH . '/helpers/global.php');

// Dispatch the request for the give URL
Dispatcher::dispatch();

That's it for set up.

Something went wrong with that request. Please try again.