3brs / sylius-404-log-plugin
404 log plugin for Sylius
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Type:sylius-plugin
Requires
- php: ^8.1
- sylius/sylius: 1.13.*|| 1.14.*
Requires (Dev)
- behat/behat: ^3.9.0
- behat/mink-selenium2-driver: ^1.4
- dmore/behat-chrome-extension: ^1.3
- dmore/chrome-mink-driver: ^2.7
- doctrine/annotations: ^2.0
- friends-of-behat/mink: ^1.10
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.1
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- php-http/message-factory: ^1.0.0
- phpstan/phpstan: ^1.12
- phpstan/phpstan-doctrine: ^1.5.7
- phpstan/phpstan-strict-rules: ^1.3.0
- phpstan/phpstan-symfony: ^1.3
- phpstan/phpstan-webmozart-assert: ^1.2.0
- phpunit/phpunit: ^9.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- rector/rector: ^1.2
- setono/sylius-redirect-plugin: ^2.7
- sylius-labs/coding-standard: ^4.2
- symfony/browser-kit: ^6.4
- symfony/debug-bundle: ^6.4
- symfony/dotenv: ^6.4
- symfony/flex: ^2.2.2
- symfony/framework-bundle: ^6.4
- symfony/http-foundation: ^6.4
- symfony/http-kernel: ^6.4
- symfony/intl: ^6.4
- symfony/web-profiler-bundle: ^6.4
Conflicts
- api-platform/core: <2.7.13
- babdev/pagerfanta-bundle: <3.6.1
- doctrine/collections: <1.7.0
- doctrine/data-fixtures: <1.5.1
- doctrine/dbal: <2.13.3
- doctrine/doctrine-bundle: <2.8.2
- friendsofsymfony/rest-bundle: <3.1.0
- jms/serializer-bundle: <4.2.0
- knplabs/knp-menu: <3.3.0
- lexik/jwt-authentication-bundle: <2.12
- masterminds/html5: <2.7.5
- polishsymfonycommunity/symfony-mocker-container: <1.0.6
- sylius/resource-bundle: <1.11.0
- symfony/css-selector: <4.4.24
- symfony/framework-bundle: >=5.4.0 <=5.4.20|>=6.0.0 <=6.0.16|>=6.1.0 <=6.1.8|>=6.2.0 <=6.2.2|6.2.8
- symfony/mime: <5.4.0
- symfony/web-link: <5.3.0
- symplify/easy-coding-standard: <10.2.0
- twig/twig: <2.14.7
- webmozart/assert: <1.11.0
- willdurand/negotiation: <3.0
README
404 Log Plugin
Features
- 404 Error Logging - Automatically logs all 404 errors with detailed information
- Smart Filtering - Configurable patterns to skip logging for admin, API, and static files
- Aggregated View - Groups identical URLs with occurrence count and timestamps
- Detailed Analytics - View statistics, trends, and individual log entries
- Multi-language Support - Available in 8 languages (EN, CS, SK, PL, DE, FR, IT, ES)
- Admin Integration - Seamless integration into Sylius admin panel
- Redirect Plugin Integration - Works perfectly with setono/sylius-redirect-plugin for complete 404 error management
Screenshots
The plugin adds a new "404 Logs" section to your Sylius admin panel where you can:
- See detailed information for each URL
- View aggregated 404 errors with occurrence counts
- Delete logs for specific URLs
- Filter by domain, URL path, and occurrence count
- View error statistics and trends
Installation
- Run
composer require 3brs/sylius-404-log-plugin
. - Register
\ThreeBRS\Sylius404LogPlugin\ThreeBRSSylius404LogPlugin
in your Kernel. - Import the plugin configuration in your
config/packages/_sylius.yaml
:- { resource: "@ThreeBRSSylius404LogPlugin/Resources/config/config.yaml" }
- Import the plugin routes in your
config/routes.yaml
:three_brs_sylius_404_log_plugin: resource: "@ThreeBRSSylius404LogPlugin/Resources/config/routes.yaml"
- Create and run doctrine database migrations:
bin/console doctrine:migrations:diff bin/console doctrine:migrations:migrate
Configuration
Skip Patterns
By default, the plugin skips logging for certain URL patterns to avoid noise. You can customize this behavior in your config/services.yaml
:
parameters: # Override default skip patterns three_brs_sylius_404_log_plugin.skip_patterns: - '/admin' # Admin section - '/api' # API endpoints - '/_' # Symfony profiler
Disable filtering (log everything):
parameters: three_brs_sylius_404_log_plugin.skip_patterns: []
Supported Languages
The plugin includes translations for:
- 🇬🇧 English (en)
- 🇨🇿 Czech (cs)
- 🇸🇰 Slovak (sk)
- 🇵🇱 Polish (pl)
- 🇩🇪 German (de)
- 🇫🇷 French (fr)
- 🇮🇹 Italian (it)
- 🇪🇸 Spanish (es)
Usage
After installation, navigate to your Sylius admin panel. You'll find a new "404 Logs" menu item that provides:
- Aggregated Log View - Overview of all unique 404 URLs with occurrence counts
- Detailed Log View - Individual log entries with timestamps and user agent information, view trends and statistics over time
- Filtering & Search - Filter logs by domain, URL path, and occurrence count
Console Commands
Log Cleanup Command
The plugin provides a console command to clean up old 404 logs automatically. This is useful for maintaining database performance and preventing excessive storage usage.
php bin/console three-brs:404-logs:cleanup [days] [options]
Arguments:
days
- Number of days to keep logs (older logs will be deleted)
Options:
--dry-run
- Show what would be deleted without actually deleting--batch-size=N
- Number of records to delete in each batch (default: 1000)
Examples:
# Delete logs older than 30 days
php bin/console three-brs:404-logs:cleanup 30
Integration with Redirect Plugins
Setono Sylius Redirect Plugin
This plugin works excellently together with setono/sylius-redirect-plugin to provide a complete 404 error management solution.
Why combine both plugins?
- 404 Log Plugin: Identifies which URLs are generating 404 errors
- Setono Redirect Plugin: Allows you to create redirects for those problematic URLs
Recommended workflow:
- Monitor 404 errors using this plugin to identify frequently accessed broken URLs
- Create redirects in the Setono Redirect Plugin admin panel for important URLs
- Track effectiveness by monitoring if 404 occurrences decrease after implementing redirects
Installation of Setono Redirect Plugin:
composer require setono/sylius-redirect-plugin
Integration benefits:
- Data-driven redirects: Use 404 logs to prioritize which redirects to create
- SEO improvement: Fix broken links that hurt search engine rankings
- Better UX: Automatically redirect users to relevant content instead of showing 404 errors
- Analytics: Monitor redirect effectiveness by tracking 404 reduction
Best practices when using both plugins:
- Review 404 logs weekly to identify new broken URLs
- Create redirects for high-traffic 404 URLs (URLs with many occurrences)
- Use meaningful redirect targets based on URL similarity or content relevance
- Monitor redirect performance by checking if specific URLs stop appearing in 404 logs
Development
Usage
- Create symlink from .env.dist to .env or create your own .env file
- Develop your plugin in
/src
- See
bin/
for useful commands
Testing
After your changes you must ensure that the tests are still passing.
$ composer install
$ bin/console doctrine:schema:create -e test
$ bin/phpstan.sh
$ bin/ecs.sh
Contributing
We welcome contributions! Please feel free to submit pull requests or open issues for bugs and feature requests.
License
This library is under the MIT license.
Credits
Developed by 3BRS