tourze / symfony-fake-404-bundle
404 错误页面
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Twig
Type:symfony-bundle
Requires
- php: >=8.1
- symfony/framework-bundle: ^6.4
- symfony/twig-bundle: ^6.4
This package is auto-updated.
Last update: 2025-03-31 00:31:14 UTC
README
A Symfony bundle that displays random custom 404 error pages instead of the default Symfony error page.
Features
- Automatically captures 404 (Not Found) errors
- Randomly displays one of the custom 404 pages
- Includes multiple pre-designed error page templates (Nginx, IIS, Tomcat, etc.)
- Easy to add new custom error pages
- Fully customizable through Twig templates
- Zero configuration required
Installation
Requirements
- PHP 8.1 or higher
- Symfony 6.4 or higher
- Symfony Twig Bundle
Via Composer
composer require tourze/symfony-fake-404-bundle
Bundle Registration
Enable the bundle in config/bundles.php
:
return [ // ... Tourze\Fake404Bundle\Fake404Bundle::class => ['all' => true], ];
Install Assets
php bin/console assets:install
Quick Start
Once installed, the bundle automatically captures all 404 errors and displays a random error page template. No additional configuration is required.
Usage
Adding Custom 404 Pages
- Create a new Twig template in
templates/bundles/Fake404Bundle/pages/
- Name your template appropriately (e.g.,
my_custom_error.html.twig
) - Extend the base template:
{% extends '@Fake404/layout.html.twig' %} {% block content %} Your custom 404 content here {% endblock %}
Built-in Templates
The bundle includes several built-in 404 page templates that mimic well-known server error pages:
- Nginx style 404 page
- IIS style 404 page
- Tomcat style 404 page
- CodeIgniter style 404 page
Contributing
Please see CONTRIBUTING.md for details.
License
The MIT License (MIT). Please see License File for more information.