Esempio n. 1
0
<?php

/* vim:set tabstop=4: vim:set shiftwidth=4: vim:set smarttab: vim:set expandtab: */
require '/home/raymond/sites/aether/Aether.php';
function routeAutoLoad($name)
{
    $path = split("/", pathinfo(__FILE__, PATHINFO_DIRNAME));
    $path = join("/", array_slice($path, 0, -1)) . "/";
    $file = $path . "libs/" . $name . ".php";
    if (file_exists($file)) {
        require_once $file;
    } else {
        return false;
    }
}
spl_autoload_register("routeAutoLoad");
/**
 * 
 * A default deployer for web
 * 
 * Created: 2010-05-29
 * @author Raymond Julin
 * @package
 */
try {
    $aether = new Aether();
    $aether->render();
} catch (Exception $e) {
    trigger_error("Uncaught error: " . $e);
}
Esempio n. 2
0
<?php

// vim:set ts=4 sw=4 et:
$path = split("/", pathinfo(__FILE__, PATHINFO_DIRNAME));
array_pop($path);
$path = join("/", $path) . "/";
require_once $path . "Aether.php";
Aether::$aetherPath = $path;
spl_autoload_register(array('Aether', 'autoLoad'));
require_once $path . 'tests/CLITest.php';
require_once $path . 'tests/ConfigTest.php';
require_once $path . 'tests/JsonCommentFilteredResponseTest.php';
require_once $path . 'tests/JsonResponseTest.php';
require_once $path . 'tests/ModuleFactoryTest.php';
require_once $path . 'tests/SectionFactoryTest.php';
require_once $path . 'tests/ServiceLocatorTest.php';
require_once $path . 'tests/UrlParserTest.php';
require_once $path . 'tests/templating/SmartyTest.php';
require_once $path . 'tests/templating/TemplateTest.php';
/**
 * 
 * Run all PHPUnit test cases for aether
 * 
 * Created: 2009-02-17
 * @author Raymond Julin
 * @package aether.test
 */
class Framework_AllTests
{
    public static function suite()
    {
Esempio n. 3
0
 /**
  * Start Aether.
  * On start it will parse the projects configuration file,
  * it will try to match the presented http request to a rule
  * in the project configuration and create some overview
  * over which modules it will need to render once
  * a request to render them comes
  *
  * @access public
  * @return Aether
  * @param string $configPath Optional path to the configuration file for the project
  */
 public function __construct($configPath = false)
 {
     self::$aetherPath = pathinfo(__FILE__, PATHINFO_DIRNAME) . "/";
     spl_autoload_register(array('Aether', 'autoLoad'));
     $this->sl = new AetherServiceLocator();
     $this->sl->set('aetherPath', self::$aetherPath);
     // Initiate all required helper objects
     $parsedUrl = new AetherUrlParser();
     $parsedUrl->parseServerArray($_SERVER);
     $this->sl->set('parsedUrl', $parsedUrl);
     // Set autoloader
     // TODO Make this more uesable
     /**
      * Find config folder for project
      * By convention the config folder is always placed at
      * $project/config, while using getcwd() MUST return the
      * $project/www/ folder
      */
     $projectPath = preg_replace("/www\\/?\$/", "", getcwd());
     $this->sl->set("projectRoot", $projectPath);
     if (!defined("PROJECT_PATH")) {
         define("PROJECT_PATH", $projectPath);
     }
     $paths = array($configPath, $projectPath . 'config/autogenerated.config.xml', $projectPath . 'config/aether.config.xml');
     foreach ($paths as $configPath) {
         if (file_exists($configPath)) {
             break;
         }
     }
     try {
         $config = new AetherConfig($configPath);
         $config->matchUrl($parsedUrl);
         $this->sl->set('aetherConfig', $config);
     } catch (AetherMissingFileException $e) {
         /**
          * This means that someone forgot to ensure the config
          * file actually exists
          */
         $msg = "No configuration file for project found: " . $e->getMessage();
         throw new Exception($msg);
     } catch (AetherNoUrlRuleMatchException $e) {
         /**
          * This means parsing of configuration file failed
          * by the simple fact that no rules matches
          * the url. This is due to a bad developer
          */
         $msg = "No rule matched url in config file: " . $e->getMessage();
         throw new Exception($msg);
     }
     $options = $config->getOptions(array('AetherRunningMode' => 'prod', 'cache' => 'off'));
     if ($options['cache'] == 'on') {
         $cacheClass = isset($options['cacheClass']) ? $options['cacheClass'] : 'AetherCache';
         $cacheOptions = isset($options['cacheOptions']) ? $options['cacheOptions'] : [];
         $cache = $this->getCacheObject($cacheClass, $cacheOptions);
         $this->sl->set("cache", $cache);
     }
     /**
      * Make sure base and root for this request is stored
      * in the service locator so it can be made available
      * to the magical $aether array in templates
      */
     $magic = $this->sl->getVector('templateGlobals');
     $magic['base'] = $config->getBase();
     $magic['root'] = $config->getRoot();
     $magic['urlVars'] = $config->getUrlVars();
     $magic['runningMode'] = $options['AetherRunningMode'];
     $magic['requestUri'] = $_SERVER['REQUEST_URI'];
     $magic['domain'] = $_SERVER['HTTP_HOST'];
     if (isset($_SERVER['HTTP_REFERER'])) {
         $magic['referer'] = $_SERVER['HTTP_REFERER'];
     }
     $magic['options'] = $options;
     /**
      * If we are in TEST mode we should prepare a timer object
      * and time everything that happens
      */
     if ($options['AetherRunningMode'] == 'test') {
         // Prepare timer
         $timer = new AetherTimer();
         $timer->start('aether_main');
         $this->sl->set('timer', $timer);
     }
     // Initiate section
     try {
         $searchPath = isset($options['searchpath']) ? $options['searchpath'] : $projectPath;
         AetherSectionFactory::$path = $searchPath;
         $this->section = AetherSectionFactory::create($config->getSection(), $this->sl);
         $this->sl->set('section', $this->section);
         if (isset($timer)) {
             $timer->tick('aether_main', 'section_initiate');
         }
     } catch (Exception $e) {
         // Failed to load section, what to do?
         throw new Exception('Failed horribly: ' . $e->getMessage());
     }
 }