no-framework-tutorial/implementation/04/src/Bootstrap.php

35 lines
648 B
PHP
Raw Normal View History

2022-05-19 21:39:08 +00:00
<?php declare(strict_types=1);
namespace Lubian\NoFramework;
use Throwable;
use Whoops\Handler\PrettyPageHandler;
use Whoops\Run;
use function error_log;
use function error_reporting;
use function getenv;
use const E_ALL;
require __DIR__ . '/../vendor/autoload.php';
$environment = getenv('ENVIRONMENT') ?: 'dev';
error_reporting(E_ALL);
$whoops = new Run;
if ($environment === 'dev') {
$whoops->pushHandler(new PrettyPageHandler);
} else {
$whoops->pushHandler(function (Throwable $t) {
error_log('ERROR: ' . $t->getMessage(), $t->getCode());
echo 'Oooopsie';
});
}
$whoops->register();
echo 'Hello World!';