You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gist/app/bootstrap.php

37 lines
796 B

<?php
require __DIR__.'/../vendor/autoload.php';
/**
* Wrap everything in a closure to preserve global scope and return the
* application.
*/
return call_user_func(function () {
$app = null;
/**
* This closure will be used to require other init files with a clean
* scope, with only access to `$app`.
*/
$closure = function () use (&$app) {
require func_get_arg(0);
};
$files = array();
foreach (new DirectoryIterator(__FILE__ . '.d') as $file) {
if (!$file->isDot() && $file->isFile() && $file->getBasename()[0] !== '.') {
$files[] = $file->getPathname();
}
}
// Sort init files, order is important
sort($files);
foreach ($files as $file) {
$closure($file);
}
return $app;
});