codebuds / easyadmin-log-viewer-bundle
A log viewer bundle for EasyAdmin 4 in Symfony applications
Installs: 50
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.2
- easycorp/easyadmin-bundle: ^4.0
- phpstan/phpstan: ^1.12
- symfony/framework-bundle: ^7.0
- symfony/twig-bundle: ^7.0
- symfony/ux-live-component: ^2.13
- symfony/ux-twig-component: ^2.13
Requires (Dev)
- phpunit/phpunit: ^10.0
- rector/rector: ^1.2
- roave/security-advisories: dev-latest
- symfony/browser-kit: ^7.1
- symfony/phpunit-bridge: ^7.0
- symfony/routing: ^7.1
- symfony/yaml: ^7.1
This package is auto-updated.
Last update: 2024-12-21 13:11:08 UTC
README
A Symfony bundle that provides a log viewer interface for EasyAdmin 4, compatible with Symfony 7 and PHP 8.3.
Features
- View log files directly from your EasyAdmin dashboard
- Download log files
- Delete log files
- Filter log entries by level and type
- Configurable route prefix
Requirements
- PHP 8.3+
- Symfony 7+
- EasyAdmin 4
Installation
Use Composer to install the bundle:
composer require codebuds/easyadmin-log-viewer-bundle
Configuration
Add the bundle to your config/bundles.php
:
return [ // ... EasyAdminLogViewerBundle::class => ['all' => true], ];
Create a configuration file config/packages/easy_admin_log_viewer.yaml
:
easy_admin_log_viewer: route_prefix: '/admin' # Default value, can be customized levels: - { level: 'INFO', class: 'info' } - { level: 'ERROR', class: 'danger' } - { level: 'CRITICAL', class: 'danger' } - { level: 'DEBUG', class: 'secondary' }
The level is what is automatically picked up from the log files. Then a CSS class can be set per level. By default the predefined Bootstrap styles can be used primary
, secondary
, success
, danger
, warning
, info
, light
, dark
Twig component
A default path has to be added to the twig_component.yaml
configuration file:
twig_component: defaults: #... CodeBuds\EasyAdminLogViewerBundle\Twig\Components\: '@EasyAdminLogViewer/components/'
Routing
The following needs to be added to the applications routes.yaml configuration file:
easy_admin_log_viewer: resource: '@EasyAdminLogViewerBundle/config/routes.yaml' prefix: '%easy_admin_log_viewer.route_prefix%'
Customizing the Route Prefix
You can customize the route prefix in your configuration:
easy_admin_log_viewer: route_prefix: '/custom-admin'
This will change all log viewer routes to start with /custom-admin
instead of the default /admin
.
Adding the log viewer to the dashboard
To see the log files the route can be added to your EasyAdmin dashboard controller:
<?php namespace App\Controller\Admin; use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController; class DashboardController extends AbstractDashboardController { #[\Override] public function configureMenuItems(): iterable { ... yield MenuItem::linktoRoute('Logs', 'fa fa-file-alt', 'easy_admin_log_viewer_list')->setPermission('ROLE_ADMIN'); ... } }
Security
Only users with ROLE_ADMIN
can access the log viewer interface. Make sure to properly secure your admin routes.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.