This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

The Dispatcher

All requests are routed through the concrete5 dispatcher. Checking out your site’s index.php, you’ll notice that it consists of a single line:


What does the dispatcher do? In order:

  • It sets up the C5_EXECUTE constant with a value of true.
if (!defined("C5_EXECUTE")) {
        define('C5_EXECUTE', true);
  • It performs several startup checks to load configuration files and makes sure the dispatcher is not being called directly.
  • We load the call the database loader:
## Load the database ##
  • Load the cache library and start the cache.
  • We load the core libraries, then the core models.
  • We load theme paths, session handlers, etc.

Finally we’re ready for the good stuff. We take the request to the dispatcher and get the matching collection object:

$req = Request::get();

If the collection cannot be found, the user is sent to /page_not_found:

switch($c->getError()) {
$v = View::getInstance();

We check for maintenance mode, then create a new permissions object for the current collection:

$cp = new Permissions($c);

Now we check to make sure there’s nothing wrong with the collection’s permissions. If an error is returned, we render /page_forbidden:

switch($cp->getError()) {
    $v = View::getInstance();

We then load the appropriate version based on the permissions object, record the page view in the site statistics table, and fire the on_page_view event:

## Fire the on_page_view Event
Events::fire('on_page_view', $c, $u)

And finally, we render the page:

$v = View::getInstance();

This section focuses on what happens when we sent a request to your concrete5 site, and how the dispatcher handles the request. If you'd like to take a look at the file for yourself, go ahead-- it's located at concrete/dispatcher. You'll notice there's a lot going on in there! As we step through each part of this file, we'll gain some insight into everything that happens behind the scenes before a page is rendered.

Loading Conversation