/**
  * Makes the path an absolute path or returns null if passed path is empty.
  *
  * @param string $path A path to absolute
  *
  * @return string The absolute path
  */
 protected function makePathAbsolute($path = '')
 {
     if (empty($path) === false) {
         return DIRECTORY_SEPARATOR . trim(DirectoryKeys::realpath($path), DIRECTORY_SEPARATOR);
     }
 }
Example #2
0
declare (ticks=1);
error_reporting(~E_NOTICE);
set_time_limit(0);
// set the session timeout to unlimited
ini_set('session.gc_maxlifetime', 0);
ini_set('zend.enable_gc', 0);
ini_set('max_execution_time', 0);
// set environmental variables in $_ENV globals per default
$_ENV = appserver_get_envs();
// load core functions to override in runtime environment
require __DIR__ . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR . 'core_functions.php';
// bootstrap the application
require __DIR__ . DIRECTORY_SEPARATOR . 'bootstrap.php';
// initialize configuration and schema file name
$configurationFileName = DirectoryKeys::realpath(sprintf('%s/%s/appserver.xml', APPSERVER_BP, DirectoryKeys::CONF));
$schemaFileName = DirectoryKeys::realpath(sprintf('%s/resources/schema/appserver.xsd', APPSERVER_BP));
// initialize the DOMDocument with the configuration file to be validated
$configurationFile = new \DOMDocument();
$configurationFile->load($configurationFileName);
// activate internal error handling, necessary to catch errors with libxml_get_errors()
libxml_use_internal_errors(true);
// validate the configuration file with the schema
if ($configurationFile->schemaValidate($schemaFileName) === false) {
    foreach (libxml_get_errors() as $error) {
        $message = "Found a schema validation error on line %s with code %s and message %s when validating configuration file %s";
        error_log(var_export($error, true));
        throw new \Exception(sprintf($message, $error->line, $error->code, $error->message, $error->file));
    }
}
// initialize the SimpleXMLElement with the content XML configuration file
$configuration = new \TechDivision\Configuration\Configuration();