Author: Gawain Lynch (gawain.lynch@gmail.com)
Inheritance: extends RuntimeExceptio\RuntimeException
Beispiel #1
0
 // and autodetect an appropriate configuration class based on this
 // information. (autoload.php path maps to a configuration class)
 $autodetectionMappings = [$boltRootPath . '/vendor/autoload.php' => [Standard::class, $boltRootPath], $boltRootPath . '/../../autoload.php' => [Composer::class, $boltRootPath . '/../../..']];
 $error = true;
 foreach ($autodetectionMappings as $autoloadPath => list($resourcesClass, $rootPath)) {
     if (!file_exists($autoloadPath)) {
         continue;
     }
     require_once $autoloadPath;
     $error = false;
     break;
 }
 // None of the mappings matched, error
 if ($error) {
     include $boltRootPath . '/src/Exception/BootException.php';
     BootException::earlyExceptionComposer();
 }
 // Register handlers early
 ShutdownHandler::register();
 /*
  * Load initialization config needed to bootstrap application.
  *
  * In order for paths to be customized and still have the standard
  * index.php (web) and nut (CLI) work, there needs to be a standard
  * place these are defined. This is ".bolt.yml" or ".bolt.php" in the
  * project root (determined above).
  *
  * Yes, YAML and PHP are supported here (not both). YAML works for
  * simple values and PHP supports any programmatic logic if required.
  */
 $config = ['application' => null, 'resources' => null, 'paths' => []];
Beispiel #2
0
    // Use resources from config, or instantiate the class based on mapping above.
    if ($config['resources'] instanceof ResourceManager) {
        $resources = $config['resources'];
    } else {
        if ($config['resources'] !== null && is_a($config['resources'], ResourceManager::class)) {
            $resourcesClass = $config['resources'];
        }
        /** @var \Bolt\Configuration\ResourceManager $resources */
        $resources = new $resourcesClass($rootPath);
    }
    // Set any non-standard paths
    foreach ((array) $config['paths'] as $name => $path) {
        $resources->setPath($name, $path);
    }
    if (!file_exists($resources->getPath('web')) && $resources instanceof Composer) {
        BootException::earlyExceptionMissingLoaderConfig();
    }
    /** @var \Bolt\Configuration\ResourceManager $config */
    $resources->verify();
    // Create the 'Bolt application'
    $appClass = Application::class;
    if ($config['application'] !== null && is_a($config['application'], Silex\Application::class, true)) {
        $appClass = $config['application'];
    }
    $app = new $appClass(['resources' => $resources]);
    // Initialize the 'Bolt application': Set up all routes, providers, database, templating, etc..
    if (method_exists($app, 'initialize')) {
        $app->initialize();
    }
    return $app;
});
Beispiel #3
0
<?php

/*
 * This could be loaded on a very old version of PHP so no syntax/methods over 5.2 in this file.
 */
use Bolt\Exception\BootException;
if (version_compare(PHP_VERSION, '5.5.9', '<')) {
    require dirname(dirname(__FILE__)) . '/src/Exception/BootException.php';
    BootException::earlyExceptionVersion();
}
if (PHP_SAPI === 'cli-server') {
    if (is_file($_SERVER['DOCUMENT_ROOT'] . preg_replace('#(\\?.*)$#', '', $_SERVER['REQUEST_URI']))) {
        return false;
    }
}
return require dirname(__FILE__) . '/bootstrap.php';