PieCrust

Running PieCrust

Here’s some developer information on how PieCrust is run.

The simplest way to bootstrap PieCrust is to put these lines in your site’s index.php (assuming you have the recommended directory structure… otherwise, adjust the require path):

require '../_piecrust/piecrust.php';
piecrust_run();
 

The piecrust_run method does the following:

  • Check PHP’s version (you need PHP v5.3 or above).
  • Set the include paths, the error and shutdown handlers, and a few other PHP environment things.
  • Set up PieCrust’s class autoloader.
  • Run PieCrust with the default options (i.e. using the current server request URL, etc.)

You can pass some parameters to piecrust_run to change the way it runs the web request:

  • An associative array that’s passed to the PieCrust constructor. It can contain any of the following:

    • root (defaults the the directory of the entry PHP script): the root of the website, where _content/config.yml lives.
    • cache: whether or not to enable caching. Defaults to true unless ?!debug has been specified on the request URL.
    • debug: whether or not to enable debug mode. Defaults to false unless ?!nocache has been specified on the request URL.
  • The URL to process. It defaults to the current request’s URL if null.

Fork me on GitHub