Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
grav-test/index.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
55 lines (45 sloc)
1.47 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package Grav.Core | |
* | |
* @copyright Copyright (C) 2014 - 2016 RocketTheme, LLC. All rights reserved. | |
* @license MIT License; see LICENSE file for details. | |
*/ | |
namespace Grav; | |
// Ensure vendor libraries exist | |
$autoload = __DIR__ . '/vendor/autoload.php'; | |
if (!is_file($autoload)) { | |
die("Please run: <i>bin/grav install</i>"); | |
} | |
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>"); | |
} | |
} | |
use Grav\Common\Grav; | |
use RocketTheme\Toolbox\Event\Event; | |
// Register the auto-loader. | |
$loader = require_once $autoload; | |
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)); | |
} | |
// 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')) { | |
die("'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 | |
) | |
); | |
// Process the page | |
try { | |
$grav->process(); | |
} catch (\Exception $e) { | |
$grav->fireEvent('onFatalException', new Event(['exception' => $e])); | |
throw $e; | |
} |