2019-03-28 17:57:56 +01:00
< ? php
/**
* @ package Grav . Core
*
2024-06-07 14:19:08 +02:00
* @ copyright Copyright ( c ) 2015 - 2024 Trilby Media , LLC . All rights reserved .
2019-03-28 17:57:56 +01:00
* @ license MIT License ; see LICENSE file for details .
*/
namespace Grav ;
2021-05-27 18:17:50 +02:00
\define ( 'GRAV_REQUEST_TIME' , microtime ( true ));
\define ( 'GRAV_PHP_MIN' , '7.3.6' );
2019-03-28 17:57:56 +01:00
if ( PHP_SAPI === 'cli-server' ) {
2021-09-16 14:44:40 +02:00
$symfony_server = stripos ( getenv ( '_' ), 'symfony' ) !== false || stripos ( $_SERVER [ 'SERVER_SOFTWARE' ] ? ? '' , 'symfony' ) !== false || stripos ( $_ENV [ 'SERVER_SOFTWARE' ] ? ? '' , 'symfony' ) !== false ;
2021-05-27 18:17:50 +02:00
if ( ! isset ( $_SERVER [ 'PHP_CLI_ROUTER' ]) && ! $symfony_server ) {
die ( " PHP webserver requires a router to run Grav, please use: <pre>php -S { $_SERVER [ 'SERVER_NAME' ] } : { $_SERVER [ 'SERVER_PORT' ] } system/router.php</pre> " );
2019-03-28 17:57:56 +01:00
}
}
2021-05-27 18:17:50 +02:00
// Ensure vendor libraries exist
$autoload = __DIR__ . '/vendor/autoload.php' ;
if ( ! is_file ( $autoload )) {
die ( 'Please run: <i>bin/grav install</i>' );
}
// Register the auto-loader.
$loader = require $autoload ;
2022-03-15 10:52:21 +01:00
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set ( @ date_default_timezone_get ());
// Set internal encoding.
@ ini_set ( 'default_charset' , 'UTF-8' );
mb_internal_encoding ( 'UTF-8' );
2021-05-27 18:17:50 +02:00
use Grav\Common\Grav ;
use RocketTheme\Toolbox\Event\Event ;
2019-03-28 17:57:56 +01:00
// Get the Grav instance
2022-03-15 10:52:21 +01:00
$grav = Grav :: instance ( array ( 'loader' => $loader ));
2019-03-28 17:57:56 +01:00
// Process the page
try {
$grav -> process ();
2022-03-15 10:52:21 +01:00
} catch ( \Error | \Exception $e ) {
2019-03-28 17:57:56 +01:00
$grav -> fireEvent ( 'onFatalException' , new Event ( array ( 'exception' => $e )));
throw $e ;
}