예제 #1
0
 /**
  * Set up the environment according to configuration file specifications
  * 
  * @param string  $configPath   The path of the folder containing Pokelio.json configuration file
  * @param string  $appRealPath  Where the consumer app is
  */
 public function __construct($configPath, $appRealPath)
 {
     //Set Pokelio Version
     $this->version = "1.1.0";
     //Config
     define('APP_CONFIG_PATH', $configPath);
     //Check if config file exists
     $configFile = APP_CONFIG_PATH . '/Pokelio.json';
     if (!file_exists($configFile)) {
         //Can´t use Pokelio_Error class to raise error here
         die("Pokelio config file [{$configFile}] not found. Can´t continue.");
     }
     //Set Pokelio path constants
     $this->setPokelioPaths();
     //Set loader function for Pokelio classes
     require POKELIO_CLASSES_PATH . '/Loader/Loader.php';
     Pokelio_Loader::setLoader();
     //Load special classes
     require POKELIO_CLASSES_PATH . '/ShortCuts.php';
     //Register Pokelio Modules
     Pokelio_Module::registerModules(POKELIO_MODULES_PATH);
     //Set consumer application path constants
     $this->setAppPaths($appRealPath);
     //Register App Modules
     Pokelio_Module::registerModules(APP_MODULES_PATH, true);
     //Load configuration file
     Pokelio_Global::loadConfigFile($configFile, 'Pokelio');
     //Set error manager
     Pokelio_Error::setErrorHandler();
     //Set fatal error manager
     Pokelio_Error::setFatalErrorHandler();
     //Disable error reporting as we are managing that
     $phpErrorReport = Pokelio_Global::getConfig('PHP_ERROR_REPORTING', 'Pokelio');
     ini_set('error_reporting', $phpErrorReport);
     //Set exception manager
     Pokelio_Exception::setExceptionHandler();
     //Set timezone
     date_default_timezone_set(Pokelio_Global::getConfig('TIMEZONE'));
     //CallBack
     Pokelio_Callback::invokeCallback('Pokelio', 'Application', 'endConfiguration');
     //Determine if CLI or WEB Session
     if (php_sapi_name() == 'cli') {
         $this->cliManager();
     } else {
         $this->webManager();
     }
 }