willy.club/routes/start.php

24 lines
626 B
PHP

<?php
use WillySoft\Http\ErrorHandler;
use WillySoft\Http\Route;
ErrorHandler::register(function($error_messages) {
view('errors/500', ['error_messages' => $error_messages]);
});
Route::get('/', fn() => view('pages/home'));
Route::get('/matrix', fn() => view('pages/matrix'));
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('templates/header', ['title' => 'Page not found']);
view('errors/404');
view('templates/footer');