"Fossies" - the Fresh Open Source Software Archive

Member "grav/index.php" (1 Sep 2020, 1710 Bytes) of package /linux/www/grav-v1.6.27.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "index.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 /**
    4  * @package    Grav.Core
    5  *
    6  * @copyright  Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
    7  * @license    MIT License; see LICENSE file for details.
    8  */
    9 
   10 namespace Grav;
   11 
   12 \define('GRAV_REQUEST_TIME', microtime(true));
   13 \define('GRAV_PHP_MIN', '7.1.3');
   14 
   15 if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
   16     die(sprintf('You are running PHP %s, but Grav needs at least <strong>PHP %s</strong> to run.', $ver, $req));
   17 }
   18 
   19 if (PHP_SAPI === 'cli-server' && !isset($_SERVER['PHP_CLI_ROUTER'])) {
   20     die("PHP webserver requires a router to run Grav, please use: <pre>php -S {$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']} system/router.php</pre>");
   21 }
   22 
   23 // Set timezone to default, falls back to system if php.ini not set
   24 date_default_timezone_set(@date_default_timezone_get());
   25 
   26 // Set internal encoding.
   27 if (!\extension_loaded('mbstring')) {
   28     die("'mbstring' extension is not loaded.  This is required for Grav to run correctly");
   29 }
   30 @ini_set('default_charset', 'UTF-8');
   31 mb_internal_encoding('UTF-8');
   32 
   33 // Ensure vendor libraries exist
   34 $autoload = __DIR__ . '/vendor/autoload.php';
   35 if (!is_file($autoload)) {
   36     die('Please run: <i>bin/grav install</i>');
   37 }
   38 
   39 // Register the auto-loader.
   40 $loader = require $autoload;
   41 
   42 use Grav\Common\Grav;
   43 use RocketTheme\Toolbox\Event\Event;
   44 
   45 // Get the Grav instance
   46 $grav = Grav::instance(
   47     array(
   48         'loader' => $loader
   49     )
   50 );
   51 
   52 // Process the page
   53 try {
   54     $grav->process();
   55 } catch (\Error $e) {
   56     $grav->fireEvent('onFatalException', new Event(array('exception' => $e)));
   57     throw $e;
   58 } catch (\Exception $e) {
   59     $grav->fireEvent('onFatalException', new Event(array('exception' => $e)));
   60     throw $e;
   61 }