Setup _bootstrap to setup Grav

This commit is contained in:
Flavio Copes 2016-01-05 11:52:07 +01:00
parent b3d18be643
commit a6b1c6b222
2 changed files with 38 additions and 0 deletions

View File

@ -1,2 +1,38 @@
<?php
// This is global bootstrap for autoloading
namespace Grav;
// Ensure vendor libraries exist
$autoload = __DIR__ . '/../vendor/autoload.php';
if (!is_file($autoload)) {
throw new \RuntimeException("Please run: <i>bin/grav install</i>");
}
use Grav\Common\Grav;
// Register the auto-loader.
$loader = require_once $autoload;
if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
throw new \RuntimeException(sprintf('You are running PHP %s, but Grav needs at least <strong>PHP %s</strong> to run.', $ver, $req));
}
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set(@date_default_timezone_get());
// Set internal encoding if mbstring loaded
if (!extension_loaded('mbstring')) {
throw new \RuntimeException("'mbstring' extension is not loaded. This is required for Grav to run correctly");
}
mb_internal_encoding('UTF-8');
// Get the Grav instance
$grav = Grav::instance(
array(
'loader' => $loader
)
);

View File

@ -1,2 +1,4 @@
<?php
// Here you can initialize variables that will be available to your tests
define('GRAV_CLI', true);