Exemple #1
0
 public static function setupConfig(Application $app)
 {
     $loader = new YamlLoader();
     $schema = new MetaYaml($loader->loadFromFile(__DIR__ . '/config_schema.yml'));
     $schema->validate($config = $loader->loadFromFile(__DIR__ . '/../config/config.yml'));
     foreach ($config as $key => $value) {
         $app->setConfig($key, $value);
     }
     if (array_key_exists('SCRIPT_NAME', $_SERVER) && is_string($_SERVER['SCRIPT_NAME']) && !empty($_SERVER['SCRIPT_NAME'])) {
         $dir = dirname($_SERVER['SCRIPT_NAME']);
     } else {
         $dir = '/';
     }
     $app->setConfig('dir', $dir);
 }
 */
$dotenv->required(['APP_ROOT', 'APP_CONFIG', 'WKHTMLTOPDF']);
/**
 * Setting up dependency container
 */
$diConfig = (require __DIR__ . '/di.php');
$container = new Container($diConfig);
/**
 * Instantiating the application
 */
$app = new Application();
$app->setContainer($container);
$app['env'] = $dotenv;
/**
 * Loading configuration
 */
if (is_file($configFile = getenv('APP_CONFIG'))) {
    foreach (Yaml::parse($configFile) as $config => $value) {
        $app->setConfig($config, $value);
    }
}
// The application path is protected from being overwritten
// Should be placed after configuration loading
$app->setConfig('path', __DIR__);
// Set locale based on environment
setlocale(LC_ALL, getenv('LANG'));
$bootstrap = new Bootstrap();
$app = $bootstrap->load($app);
$app['stack'] = new Builder();
$app['stack']->push('Indigo\\Guardian\\Stack\\Authentication', $app['Indigo\\Guardian\\SessionAuth'], ['delegateCaller' => true]);
return $app;