index.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Grav;
  3. if (version_compare($ver = PHP_VERSION, $req = '5.4.0', '<')) {
  4. throw new \RuntimeException(sprintf('You are running PHP %s, but Grav needs at least <strong>PHP %s</strong> to run.', $ver, $req));
  5. }
  6. // Ensure vendor libraries exist
  7. $autoload = __DIR__ . '/vendor/autoload.php';
  8. if (!is_file($autoload)) {
  9. throw new \RuntimeException("Please run: <i>bin/grav install</i>");
  10. }
  11. use Grav\Common\Grav;
  12. // Register the auto-loader.
  13. $loader = require_once $autoload;
  14. // Set timezone to default, falls back to system if php.ini not set
  15. date_default_timezone_set(@date_default_timezone_get());
  16. // Set internal encoding if mbstring loaded
  17. if (!extension_loaded('mbstring')) {
  18. throw new \RuntimeException("'mbstring' extension is not loaded. This is required for Grav to run correctly");
  19. }
  20. mb_internal_encoding('UTF-8');
  21. // Get the Grav instance
  22. $grav = Grav::instance(
  23. array(
  24. 'loader' => $loader
  25. )
  26. );
  27. // Process the page
  28. try {
  29. $grav->process();
  30. } catch (\Exception $e) {
  31. $grav->fireEvent('onFatalException');
  32. throw $e;
  33. }