print Scorpio2 Introduction


Unlike Symfony 2, Scorpio 2 has split configuration - there is the config for the dependency injection container (DIC) and then there is the platform level config that is not injected into the DIC, but is accessed via a ConfigProvider. This is essential as otherwise the configuration would not be modifiable if it were all contained in the DIC (a'la Symfony2).

Currently Scorpio2 requires at least 3 main "config" files:

DIC Config: container.yml

Please note: at the time of writing the basic DIC configuration has not been finalised and is using a port of the Symfony2 framework bundle config. This is subject to change as the container configuration is finalised.

container.yml sets up the shared configuration that is used by all components within Scorpio. This is across sites and CLI applications. It should only contain components that do not need to be overridden or that are not specific to a single entity.

Currently the file format and extension is fixed as YAML, however this will be updated to allow this file to use XML and PHP.

The current file has the following structure:


    # general configuration
    charset:              "UTF-8"
    secret:               ""
    ide:                  ""
    default_locale:       "en"

    # router configuration
        http_port:            80
        https_port:           443

    # session configuration
        auto_start:           true
        name:                 ScorpioSession
        cookie_lifetime:      86400
        cookie_path:          /
        cookie_secure:        ~
        cookie_httponly:      ~

    # templating configuration
        assets_version:       ~
        assets_version_format:  "%%s?%%s"
            http:                 []
            ssl:                  []
        cache:                ~
        engines:              ["php", "smarty"]
        loaders:              []

    # translator configuration
        enabled:              true
        fallback:             en

Master Config: config.xml

Just like previous versions of Scorpio, there is a single master config file that is used throughout the whole platform. In Scorpio2 this is separate from the DIC config as the DIC config is cached into the DIC itself and cannot be changed. This config however, can be modified once loaded.

Unlike previous versions of Scorpio, the format of the config file has changed: it can now use a more freeform XML format.

The database config, logging etc is all defined within this file. Typically it will contain something like the following:

<?xml version="1.0" encoding="UTF-8" ?>
	<app override="0">
		<author override="0">Your Name</author>
		<copyright override="0">Your Company (c) 2012</copyright>
		<version override="0">X.Y</version>

Bootstrap: init.php

init.php is the shared bootstrap file used by both web and CLI components. This sets up the autoloader, DIC, main config and environment. It currently is some variation of the following code sample:

 * init.php
 * init.php provides the main bootstrapping and setup for the Scorpio environment.
 * You can change this to suit your needs / update the packages. This is just to
 * get you started.
 * @author Dave Redfern
 * @copyright Dave Redfern (c) 2007-2012
 * @package init.d
 * @subpackage init
 * @license  BSD License

 * Location of the vendor packages
$vendorDir = dirname(dirname(__DIR__)).'/vendor';
 * Main custom source directory
$sourceDir = dirname(dirname(__DIR__)).'/src';
 * Compiled all-in-one class built from {@link Scorpio\Framework\Package\Packager}.
$bootstrap = __DIR__.'/bootstrap.php';

 * If we have a bootstrap, use it, otherwise load the autoloader
if ( file_exists($bootstrap) ) {
	include_once $bootstrap;
} else {
	$autoload = '/Scorpio/Framework/Autoload/Autoload.php';
	if ( file_exists($vendorDir.$autoload) ) {
		include_once $vendorDir.$autoload;
	} elseif ( file_exists($sourceDir.$autoload) ) {
		include_once $sourceDir.$autoload;
	} else {
		throw new \Exception(
				'Unable to load Autoload.php from either "%s" or "%s". Please correct the paths.',
				$vendorDir.$autoload, $sourceDir.$autoload

use Scorpio\Framework\Autoload\Autoload;

 * Register default autoloader and required packages
$oLoader = Autoload::setInstance(new Autoload());
		'Scorpio' => dirname($vendorDir) . '/src',
		'Symfony\\Component\\Yaml' => $vendorDir . '/symfony/yaml',
		'Symfony\\Component\\Templating' => $vendorDir . '/symfony/templating',
		'Symfony\\Component\\Routing' => $vendorDir . '/symfony/routing',
		'Symfony\\Component\\HttpKernel' => $vendorDir . '/symfony/http-kernel',
		'Symfony\\Component\\HttpFoundation' => $vendorDir . '/symfony/http-foundation',
		'Symfony\\Component\\Finder' => $vendorDir . '/symfony/finder',
		'Symfony\\Component\\EventDispatcher' => $vendorDir . '/symfony/event-dispatcher',
		'Symfony\\Component\\DependencyInjection' => $vendorDir . '/symfony/dependency-injection',
		'Symfony\\Component\\Console' => $vendorDir . '/symfony/console',
		'Symfony\\Component\\Config' => $vendorDir . '/symfony/config',
		'Doctrine\\ORM' => $vendorDir . '/doctrine/orm/lib',
		'Doctrine\\DBAL' => $vendorDir . '/doctrine/dbal/lib',
		'Doctrine\\Common' => $vendorDir . '/doctrine/common/lib',

 * Register "old" style packages and libs
		'Smarty' => $vendorDir . '/smarty/smarty/libs',
		'PHPExcel' => $vendorDir . '/CodePlex/PHPExcel',

 * Install autoloader

 * Start the Scorpio Bootstrap
$oBootstrap = new Scorpio\Framework\Bootstrap\Bootstrap(
	new Scorpio\Framework\Bootstrap\BootstrapBundles(
			new Scorpio\Framework\FrameworkBundle(),
			new Scorpio\SmartyTemplating\SmartyBundle()
		'production' => false,