public static function get($router, SmoothApplication $application) { if ($router == 'default') { $router = 'pattern'; } switch ($router) { case 'pattern': smooth_load('routers/pattern'); return new SmoothPatternRouter($application); default: throw new SmoothSetupException('Unknown Smooth router ' . '"' . $router . '".'); } }
<?php // Smooth: The PHP framework that goes down easy. // Copyright © 2008 Carleton College. smooth_load('configuration', 'errors', 'routing', 'controller', 'request', 'response', 'middleware'); class SmoothApplication { public $root; public $config; public $router; public $environment; public function __construct($root = null, $runtime_config = null) { $this->config = new SmoothConfiguration(); if (!$root) { // Automatically determine the application root. $root = dirname($_SERVER['SCRIPT_FILENAME']); } $this->root = $root; $env = $runtime_config && $runtime_config['environment'] ? $runtime_config['environment'] : 'development'; $this->loadConfiguration($env); if ($runtime_config) { $this->config->merge($runtime_config); } $this->environment = $env; $router = $this->config->get('smooth/router', 'default'); $this->router = SmoothRouter::get($router, $this); } public function run() { $request = new SmoothRequest();
<?php // Smooth: The PHP framework that goes down easy. // Copyright © 2008 Carleton College. class Smooth { const VERSION = '0.1.0'; } smooth_load('application');
<?php // Smooth: The PHP framework that goes down easy. // Copyright © 2008 Carleton College. smooth_load('view', 'application', 'request', 'response'); class SmoothController { public $application; public $name; protected $request; protected $response; private $rendered; public function __construct($name, SmoothApplication $app, SmoothRequest $req, SmoothResponse $response) { $this->application = $app; $this->name = $name; $this->request = $req; $this->response = $response; $this->rendered = false; } public function rendered() { return $this->rendered; } public function render($name, $context = null) { $parts = explode('/', $name, 2); list($controller, $view) = count($parts) == 1 ? array($this->name, $name) : $parts; $path = path_join($this->application->root, 'views', $controller, "{$view}.php"); if (!file_exists($path)) { return false;