This bundle adds entities for redirects and 404 errors.
For redirects, 404 errors are intercepted and the requested path is looked up. If a match is found it redirects to the found redirect's destination. The count and last accessed date are updated as well. A redirect form type and validation is available as well.
404 errors can be logged as well. Each 404 error is it's own record in the database. The path, full URL, timestamp, and referer are stored. Storing each error as a separate record allows viewing statistics over time and seeing all the referer URLs. When a redirect is created or updated, 404 records that match it's path are deleted.
Repository Branch | Version | Symfony Compatibility | PHP Compatibility | Status |
---|---|---|---|---|
2.x |
2.x |
5.4 , and 6.x |
8.0.2 or higher |
New features and bug fixes |
1.x |
1.x |
4.4 , and 5.x |
7.2.5 or higher |
No longer maintained |
Add our recipes endpoint
{
"extra": {
"symfony": {
"endpoint": [
"https://api.github.com/repos/agence-adeliom/symfony-recipes/contents/index.json?ref=flex/main",
...
"flex://defaults"
],
"allow-contrib": true
}
}
}
Install with composer
composer require agence-adeliom/easy-redirect-bundle
php bin/console doctrine:migration:diff
php bin/console doctrine:migration:migrate
php bin/console doctrine:schema:update --force
Go to your dashboard controller, example : src/Controller/Admin/DashboardController.php
<?php
namespace App\Controller\Admin;
...
use Adeliom\EasyRedirectBundle\Admin\EasyRedirectTrait;
class DashboardController extends AbstractDashboardController
{
...
use EasyRedirectTrait;
...
public function configureMenuItems(): iterable
{
...
yield from $this->configRedirectEntry();
...
# config/packages/easy_redirect.yaml
easy_redirect:
redirect_class: ~ # Required and must be an instance of "Adeliom\EasyRedirectBundle\Entity\Redirect"
not_found_class: ~ # Required and must be an instance of "Adeliom\EasyRedirectBundle\Entity\NotFound"
model_manager_name: ~ # If a custom model manager is used by default its 'default'
# When enabled, when a redirect is updated or created, the NotFound entites with a matching path are removed.
remove_not_founds: true