2014-08-02 21:11:33 +02:00
< ? php
2018-08-24 10:31:51 +02:00
2016-07-12 00:07:14 +02:00
/**
* @ package Grav . Core
*
2017-12-11 23:08:05 +01:00
* @ copyright Copyright ( C ) 2015 - 2018 Trilby Media , LLC . All rights reserved .
2016-07-12 00:07:14 +02:00
* @ license MIT License ; see LICENSE file for details .
*/
2014-08-18 13:13:51 +02:00
namespace Grav ;
2018-08-24 10:31:51 +02:00
2018-10-16 12:12:26 +02:00
\define ( 'GRAV_REQUEST_TIME' , microtime ( true ));
2018-10-12 11:06:10 +02:00
\define ( 'GRAV_PHP_MIN' , '7.1.3' );
2014-08-02 21:11:33 +02:00
2018-10-12 11:06:10 +02: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 ));
2014-08-20 13:51:03 +02:00
}
2014-08-06 20:46:49 +02:00
2018-10-12 11:06:10 +02:00
if ( PHP_SAPI === 'cli-server' && ! 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> " );
2016-12-17 15:07:40 +01:00
}
2018-10-12 11:06:10 +02:00
// Ensure vendor libraries exist
$autoload = __DIR__ . '/vendor/autoload.php' ;
if ( ! is_file ( $autoload )) {
die ( 'Please run: <i>bin/grav install</i>' );
2015-12-28 18:46:14 +01:00
}
2017-02-16 10:16:30 +01:00
// Register the auto-loader.
2018-08-24 10:31:51 +02:00
$loader = require $autoload ;
2017-02-16 10:16:30 +01:00
2018-10-12 11:06:10 +02:00
use Grav\Common\Grav ;
use RocketTheme\Toolbox\Event\Event ;
2015-02-14 18:38:01 +01: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 21:11:33 +02:00
2015-09-10 20:49:38 +02:00
// Set internal encoding if mbstring loaded
2018-10-12 11:06:10 +02:00
if ( ! \extension_loaded ( 'mbstring' )) {
2016-03-17 20:33:32 +01:00
die ( " 'mbstring' extension is not loaded. This is required for Grav to run correctly " );
2015-09-10 20:49:38 +02:00
}
mb_internal_encoding ( 'UTF-8' );
2015-02-14 18:38:01 +01:00
// Get the Grav instance
2014-08-18 13:13:51 +02:00
$grav = Grav :: instance (
2014-09-04 02:43:15 +02:00
array (
2014-10-14 06:23:13 +02:00
'loader' => $loader
2014-09-04 02:43:15 +02:00
)
2014-08-18 13:13:51 +02:00
);
2015-02-14 18:38:01 +01:00
// Process the page
2014-08-06 11:51:49 +02:00
try {
$grav -> process ();
2018-10-12 11:06:10 +02:00
} catch ( \Error $e ) {
$grav -> fireEvent ( 'onFatalException' , new Event ( array ( 'exception' => $e )));
throw $e ;
2014-08-06 11:51:49 +02:00
} catch ( \Exception $e ) {
2017-02-16 10:16:30 +01:00
$grav -> fireEvent ( 'onFatalException' , new Event ( array ( 'exception' => $e )));
2014-08-06 11:51:49 +02:00
throw $e ;
}