Skip to content

Instantly share code, notes, and snippets.

@adrolter
Created August 18, 2014 06:23
Show Gist options
  • Save adrolter/9b94e2f2292586702495 to your computer and use it in GitHub Desktop.
Save adrolter/9b94e2f2292586702495 to your computer and use it in GitHub Desktop.
More flexible bootstrap
<?php
$dirSep = DIRECTORY_SEPARATOR;
$boltRoot = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..');
$autoloaderPaths = array(
'Standard' => $boltRoot . $dirSep . 'vendor' . $dirSep . 'autoload.php',
'Composer' => $boltRoot . $dirSep . '..' . $dirSep . '..' . $dirSep . 'autoload.php';
);
foreach ($autoloaderPaths as $name => $path) {
if (file_exists($path)) {
require_once $path;
$configClass = 'Bolt\\Configuration\\' . $name;
$config = new $configClass($boltRoot);
break;
}
}
if (!isset($config) || !$config instanceof \Bolt\Configuration\ResourceManager) {
throw new Exception('Autoloader not found or configuration class instantiation failed.');
}
$config->verify();
$config->compat();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment