print Scorpio2 Introduction

Websites and Launching

Scorpio2 continues to support the site-hierarchy and inheritance from previous versions, however it has been reworked. Each site still has its own config and routing files except now the routing uses the Symfony 2 routing format and the config is much simple and follows the more freeform examples.

Website configuration is located within /etc/websites and is organised by site domain name without any leading type sub-domains (e.g. www, rss, xml). At the very minimum there will be at least one file per site: config.xml (or ini, yml, php). If the site is intended to be usable it will need a routing.xml (ini, yml, php) file. Note: the routing file is unique for each site and is not inherited but can use import definition of other route files - so long as they can be resolved.

Website controllers, models and views are now located within /src/websites. Unlike previous versions there are substantial differences in the actual format of these components. Each "site" is now just a container for essentially "undefined bundles". Basically controllers / models / views are organised into packages following the following convention:

An example component might be a "Blog" within "example.com":

/src/websites/example.com/Blog/Controller/BlogController.php

With view templates located in:

/src/websites/example.com/views/Blog/Blog

A site can contain controllers or just views or nothing if it has no customisations.

Scorpio2 is designed to use Smarty as the template layer, however it implements the Symfony2 "templating" PHP engine as well. The engine can be switched by setting the template extension to either .tpl for Smarty or .php for the PHP engine. Additional engines can be added for other templating systems and defined in the container configuration.

To handle basic websites a main rewrite handler implementation is needed. This can be as basic as the following example, which will also need a .htaccess modrewrite rule to direct requests to it.

/**
 * Web Distributor
 *
 * Stored in index.php
 *
 * @author Dave Redfern
 * @copyright Dave Redfern (c) 2007-2012
 * @package web
 * @subpackage index.php
 * @license http://www.scorpioframework.com/static/license  BSD License
 */
require_once dirname(__DIR__).'/etc/init.d/init.php';

use Symfony\Component\HttpFoundation\Request;

$oBootstrap
	->getContainer()
	->get('distributor')
		->handle(Request::createFromGlobals())
		->send();

Finally: to get a site working you will need to create the site definitions, routing config and define at least a single controller. Continuing the example above, the BlogController could be implemented in the following manner:

namespace Blog\Controller;
use Scorpio\Framework\Controller\Controller as BaseController;
use Symfony\Component\HttpFoundation\Response;

class BlogController extends BaseController {

	function indexAction() {
		return $this->get('templating')->renderResponse('Blog:Blog:index.html.tpl');
	}
}

Scorpio2 uses the same controller conventions as Symfony2.