Exemplo n.º 1
0
 /**
  * The constructor
  *
  * @param string $appBaseDir - The dir containing /App directory
  * @param string $appName
  * @param string $uri
  * @throws Exception
  */
 public function __construct($appBaseDir, $appName = "Www", $uri = null)
 {
     if (!$uri) {
         $uri = implode("/", Http\Request::getUrlSegments());
     }
     Env::setAppRootDir($appBaseDir);
     $appName = self::formatName($appName);
     if (!is_dir(Env::getAppRootDir())) {
         throw new Exception("The application root: 'App' directory doesn't\n                                exist at: " . Env::getAppRootDir());
     } else {
         Autoloader::register(dirname(Env::getAppRootDir()));
         $this->appDir = Env::getAppRootDir() . "/{$appName}";
         if (!is_dir($this->appDir)) {
             throw new Exception("The application name: '{$appName}' doesn't\n                                    exist at: " . $this->appDir);
         }
         $this->setUri($uri);
         $this->baseNamespace = "App\\{$appName}";
         $this->config = (new Config("VoodooApp"))->loadFile($this->appDir . "/Config" . Config::EXT);
         $routes = (new Config("AppRoutes"))->loadFile($this->appDir . "/Routes" . Config::EXT);
         $this->setRouting($routes->get("path") ?: []);
         if ($this->config->get("application.defaultModule")) {
             $this->defaultModule = $this->config->get("application.defaultModule");
         }
         if ($this->config->get("application.defaultController")) {
             $this->defaultController = $this->config->get("application.defaultController");
         }
     }
 }
Exemplo n.º 2
0
<?php

/**
 * -----------------------------------------------------------------------------
 * VoodooPHP
 * -----------------------------------------------------------------------------
 * @author      Mardix (http://twitter.com/mardix)
 * @github      https://github.com/mardix/Voodoo
 * @package     VoodooPHP
 *
 * @copyright   (c) 2012 Mardix (http://github.com/mardix)
 * @license     MIT
 * -----------------------------------------------------------------------------
 *
 * @name    autoload
 * @desc    Setup the voodoo autoload. Include this file in your front controller 
 *          or anywhere that is using Voodoo
 */
const REQUIRE_PHP_VERSION = "5.4";
ini_set('display_errors', '0');
// Chek PHP Version
if (version_compare(PHP_VERSION, REQUIRE_PHP_VERSION, '<')) {
    echo "VoodooPHP requires PHP " . REQUIRE_PHP_VERSION . " or greater";
    exit;
}
// Set the Voodoo Autoload
require_once __DIR__ . "/Core/Autoloader.php";
\Voodoo\Core\Autoloader::register(dirname(__DIR__));