setAppRootDir() public static method

Set the app dir
public static setAppRootDir ( $rootDir )
Beispiel #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");
         }
     }
 }
Beispiel #2
0
// @var bool - To indicate the bootstrap to load Voodoo with compose
define("LOAD_VOODOO_WITH_COMPOSER", true);
//  @var string - The directory of the composer vendor
define("COMPOSER_VENDOR_DIR", APP_ROOT_DIR . "/vendor");
// @var string - The root directory which contains /Voodoo
define("VOODOO_ROOT_DIR", APP_ROOT_DIR);
/**
 * @var string
 * Leave blank if your config files are at the based of /App/_conf
 * If you create multiple environment, ie: /App/_conf/production, /App/_conf/stage, /App/_conf/dev
 * Set the name of the subdirectory, ie: 'production'
 */
define("APP_CONFIG_DIRNAME", "");
/**
 * To load Voodoo with composer or as self
 */
if (LOAD_VOODOO_WITH_COMPOSER) {
    include_once COMPOSER_VENDOR_DIR . "/autoload.php";
} else {
    include_once VOODOO_ROOT_DIR . "/Voodoo/autoload.php";
}
// Autoload classes at the root
Voodoo\Core\Autoloader::register(APP_ROOT_DIR);
// Set the ENV path
Env::setAppRootDir(APP_ROOT_DIR);
// Set the config name. A sub directory name under /App/_conf/$subdirectory
Env::setConfigPath(APP_CONFIG_DIRNAME);
// Set the system timezone
date_default_timezone_set(Config::System()->get("timezone"));
// Error Reporting
error_reporting(Config::System()->get("errorReporting"));