Files
Grav/index.php

57 lines
1.5 KiB
PHP
Raw Normal View History

2014-08-02 12:11:33 -07:00
<?php
2016-07-11 16:07:14 -06:00
/**
* @package Grav.Core
*
* @copyright Copyright (C) 2014 - 2017 RocketTheme, LLC. All rights reserved.
2016-07-11 16:07:14 -06:00
* @license MIT License; see LICENSE file for details.
*/
2014-08-18 14:13:51 +03:00
namespace Grav;
define('GRAV_PHP_MIN', '5.5.9');
2014-08-02 12:11:33 -07:00
2015-02-14 10:38:01 -07:00
// Ensure vendor libraries exist
$autoload = __DIR__ . '/vendor/autoload.php';
if (!is_file($autoload)) {
die("Please run: <i>bin/grav install</i>");
}
2014-08-06 12:46:49 -06:00
if (PHP_SAPI == 'cli-server') {
if (!isset($_SERVER['PHP_CLI_ROUTER'])) {
die("PHP webserver requires a router to run Grav, please use: <pre>php -S {$_SERVER["SERVER_NAME"]}:{$_SERVER["SERVER_PORT"]} system/router.php</pre>");
}
}
2014-08-18 14:13:51 +03:00
use Grav\Common\Grav;
use RocketTheme\Toolbox\Event\Event;
2014-08-02 12:11:33 -07:00
if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
die(sprintf('You are running PHP %s, but Grav needs at least <strong>PHP %s</strong> to run.', $ver, $req));
}
// Register the auto-loader.
$loader = require_once $autoload;
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
2016-03-17 21:13:24 +01:00
if (!extension_loaded('mbstring')) {
die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
2015-09-10 12:49:38 -06:00
}
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(
array(
'loader' => $loader
)
2014-08-18 14:13:51 +03:00
);
2015-02-14 10:38:01 -07:00
// Process the page
try {
$grav->process();
} catch (\Exception $e) {
$grav->fireEvent('onFatalException', new Event(array('exception' => $e)));
throw $e;
}