The framework provides configurable error pages for HTTP errors and maintenance mode.
Error page templates are configured in config/app.php:
return [
// ... other config
'error404' => [
'template' => 'errors/404.twig',
],
'maintenance' => [
'template' => 'maintenance.twig',
'message' => 'Service temporarily unavailable for maintenance',
],
];When a route is not found, the framework renders a 404 error page.
| Variable | Description |
|---|---|
{{ path }} |
The requested URL path |
{{ method }} |
The HTTP method (GET, POST, etc.) |
{{ debug }} |
Boolean for debug mode |
Create resources/views/errors/404.twig:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>404 - Page Not Found</title>
</head>
<body>
<h1>404</h1>
<p>Sorry, the page was not found.</p>
<p>Method: GET</p>
<!-- Debug info shows when APP_DEBUG=true -->
</body>
</html>To disable the custom template and use the default inline HTML:
'error404' => [
'template' => null,
],When MAINTENANCE=1 is set in the environment, all requests return a 503 maintenance page.
| Variable | Description | Default |
|---|---|---|
MAINTENANCE |
Enable maintenance mode (0 or 1) | 0 |
MAINTENANCE_TIME |
Estimated recovery time in seconds | 300 |
| Variable | Description |
|---|---|
{{ message }} |
The maintenance message from config |
{{ estimated_recovery }} |
ISO 8601 formatted recovery time |
Create resources/views/maintenance.twig:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Under Maintenance</title>
</head>
<body>
<h1>Under Maintenance</h1>
<p>{{ message }}</p>
<p>Estimated recovery: {{ estimated_recovery }}</p>
</body>
</html>To disable the custom template and use the default inline HTML:
'maintenance' => [
'template' => null,
'message' => 'We will be back soon!',
],The framework includes default templates in resources/views/:
errors/404.twig- Default 404 pagemaintenance.twig- Default maintenance page
These can be overridden by creating your own templates and updating the config.