willy.club/routes/start.php

33 lines
847 B
PHP

<?php
use WillySoft\Http\ErrorHandler;
use WillySoft\Http\Route;
// enable debug here so we display config parse errors to the user
$debug = true;
ErrorHandler::register(function($error_messages) use (&$debug) {
if ($debug) {
view('errors/500', ['error_messages' => $error_messages]);
} else {
view('errors/500', ['error_messages' => []]);
}
});
// if config loads successfully use that value instead
$debug = config('debug');
unset($debug);
Route::get('/', fn() => view('pages/home'));
Route::group(function() {
require __DIR__ . '/willychat.php';
});
Route::get('/test/$whatever?', function($whatever = 'Default Value') {
echo htmlspecialchars($whatever);
});
Route::get('/error', fn() => 1 / 0);
// since no route was matched we show a page not found error
http_response_code(404);
view('errors/404');