Parable Documentation

Parable Framework#

Using the Parable Framework with the default structure is pretty straightforward.

To install the default structure, if you haven't yet, follow the instructions in Installation.

The default structure offers a skeleton setup with all elements in place as an example.


Parable has a number of files/classes it'll look for and load if they are present. The most important of these will be \Config\App in app/Config/App.php. This is where all the setup is done for Parable, including further config files, routing files, init files, and console commands.

Flow of Parable#

  1. Parable starts by instancing the \Parable\Framework\App class.
  2. It then loads \Config\App if it exists. If there are any additional config files defined in the config array, it'll load those too, in order of definition.
  3. It then loads any inits defined in parable.inits and initializes them. Init functionality should be defined in the __construct() and from this point on, it's possible to hook into events.
  4. Routes will be loaded, if any routing classes are defined in parable.routes, and all routes will be loaded.
  5. If configured, the database connection is created. From this point on, events triggered will have database-access.
  6. Parable attempts to match the current url to a route.
    • Match found: dispatch the Route.
    • Match not found: 404, stop handling.

If matched, the Dispatcher takes over at this point, and it will handle the Route as it's configured.

Parable's default \Config\App structure#

namespace Config;

class App implements \Parable\Framework\Interfaces\Config
    public function get()
        return [
            "parable" => [
                "app" => [
                    "title" => "Parable",
                    "homedir" => "public",
                "debug" => true,
                "timezone" => "Europe/Amsterdam",
                "session" => [
                    "auto-enable" => true,
                "database" => [
                    "type" => \Parable\ORM\Database::TYPE_MYSQL,
                    "location"     => "localhost",
                    "username"     => "username",
                    "password"     => "password",
                    "database"     => "database",
                    "soft-quoting" => true,
                "mail" => [
                    "sender" => \Parable\Mail\Sender\PhpMail::class,
                    "from"   => [
                        "email" => "noreply@localhost",
                        "name"  => "No Reply",
                "configs" => [
                "commands" => [
                "inits" => [
                "routes" => [

Parable config values#

The following configuration values are automatically picked up by Parable:

ParameterTypeInfo the publicly accessible files and index.php can be found.
parable.commandsarrayA list of commands to load.
parable.configsarrayA list of additional configs to load.
parable.database.typestring\Parable\ORM\Database::TYPE_MYSQL or TYPE_SQLITE
parable.database.locationstringFor TYPE_SQLITE the location of the database file. For TYPE_MYSQL the host.
parable.database.usernamestringOnly for TYPE_MYSQL.
parable.database.passwordstringOnly for TYPE_MYSQL.
parable.database.databasestringOnly for TYPE_MYSQL.
parable.database.soft-quotingboolWhether to allow soft quoting or force the need for a Database instance.
parable.debugboolEnable displaying errors, default false.
parable.initsarrayA list of inits to load.
parable.mail.senderstringThe mail sender class to be used.
parable.mail.from.emailstringThe email address to send mail as.
parable.mail.from.namestringThe name to send mail as.
parable.routesarrayA list of routes files to load. sessions by default or not. Default true.
parable.timezonestringA timezone string in the form of Europe/Amsterdam will be set as default.

To get a config value from the Config class, call $config->get("");. The dot-notation (so is a shorthand for getting to nested values. So when this documentation says, that's what we're referring to.

None of the values in the default structure's Config are required. They're handy, but they're not required. Instead of setting the Database config in here, you could simply create a new instance yourself and setting the config on that instead.

What's most useful is the additional configs, commands, inits and routes.

Edit on GitHub