2014-08-02 12:11:33 -07:00
|
|
|
<?php
|
2014-08-18 14:13:51 +03:00
|
|
|
namespace Grav;
|
2014-08-02 12:11:33 -07:00
|
|
|
|
2014-08-06 12:46:49 -06:00
|
|
|
if (version_compare($ver = PHP_VERSION, $req = '5.4.0', '<')) {
|
2015-02-18 12:24:35 -07:00
|
|
|
throw new \RuntimeException(sprintf('You are running PHP %s, but Grav needs at least <strong>PHP %s</strong> to run.', $ver, $req));
|
2014-08-06 12:46:49 -06:00
|
|
|
}
|
2014-09-05 12:58:56 -07:00
|
|
|
|
2015-02-14 10:38:01 -07:00
|
|
|
// Ensure vendor libraries exist
|
2014-08-20 14:51:03 +03:00
|
|
|
$autoload = __DIR__ . '/vendor/autoload.php';
|
|
|
|
|
if (!is_file($autoload)) {
|
2015-02-18 12:24:35 -07:00
|
|
|
throw new \RuntimeException("Please run: <i>bin/grav install</i>");
|
2014-08-20 14:51:03 +03:00
|
|
|
}
|
2014-08-06 12:46:49 -06:00
|
|
|
|
2014-08-18 14:13:51 +03:00
|
|
|
use Grav\Common\Grav;
|
2014-08-02 12:11:33 -07:00
|
|
|
|
2014-08-20 12:18:26 +03:00
|
|
|
// Register the auto-loader.
|
2014-08-20 14:51:03 +03:00
|
|
|
$loader = require_once $autoload;
|
2014-08-02 12:11:33 -07:00
|
|
|
|
2015-02-14 10:38:01 -07:00
|
|
|
// Set timezone to default, falls back to system if php.ini not set
|
|
|
|
|
date_default_timezone_set(@date_default_timezone_get());
|
2014-08-02 12:11:33 -07:00
|
|
|
|
2015-09-10 12:49:38 -06:00
|
|
|
// 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');
|
|
|
|
|
|
2015-02-14 10:38:01 -07:00
|
|
|
// Get the Grav instance
|
2014-08-18 14:13:51 +03:00
|
|
|
$grav = Grav::instance(
|
2014-09-03 17:43:15 -07:00
|
|
|
array(
|
2014-10-13 22:23:13 -06:00
|
|
|
'loader' => $loader
|
2014-09-03 17:43:15 -07:00
|
|
|
)
|
2014-08-18 14:13:51 +03:00
|
|
|
);
|
|
|
|
|
|
2015-02-14 10:38:01 -07:00
|
|
|
// Process the page
|
2014-08-06 12:51:49 +03:00
|
|
|
try {
|
|
|
|
|
$grav->process();
|
|
|
|
|
} catch (\Exception $e) {
|
2014-08-19 18:45:42 +03:00
|
|
|
$grav->fireEvent('onFatalException');
|
2014-08-06 12:51:49 +03:00
|
|
|
throw $e;
|
|
|
|
|
}
|
2014-08-02 12:11:33 -07:00
|
|
|
|