@Loggable annotations to enable declarative logging, which aligns with modern PHP/Laravel architectures seeking separation of concerns (SoC) and reduced boilerplate. This fits well in microservices, layered applications, or monoliths with modular logging needs.ProxyManager), which is battle-tested but may require explicit configuration.@Loggable (mitigated by lazy loading or whitelisting critical paths).| Risk Area | Mitigation Strategy |
|---|---|
| Proxy Generation | Test with opcache.enable_cli=1 and benchmark proxy creation time. |
| Annotation Pollution | Use namespace-scoped annotations or exclude vendor/third-party classes. |
| Logging Overhead | Configure log level thresholds (e.g., DEBUG for dev, INFO for prod). |
| Symfony AOP Deprecation | Monitor Symfony’s AOP stack for breaking changes (e.g., ProxyManager v3+). |
| Thread Safety | Ensure logging is async (Monolog async handlers) if used in concurrent contexts. |
@Loggable apply to all methods in a class, or require per-method annotations?@Loggable(class: UserRepository::class, methods: ['findById']).laravel-debugbar or spatie/laravel-logging-traits.goaop/go-aop.doctrine/annotations (auto-loaded via Composer).ContainerInterface, EventDispatcher).composer.json and configure in config/bundles.php:
return [
Dmp\LoggableBundle\LoggableBundle::class => ['all' => true],
];
UserService::find()) and verify logs.APP_LOGGABLE_ENABLED) for gradual rollout.App\Jobs\*).DEBUG in local, WARN in prod).laravel-debugbar.| Component | Compatibility Notes |
|---|---|
| Laravel 8/9/10 | Tested; uses Symfony 5.4+ components. |
| PHP 8.0+ | Requires PHP 8.0+ for attributes (if using #[Loggable] syntax). |
| Monolog Handlers | Works with all Monolog handlers (e.g., StreamHandler, SyslogHandler). |
| Custom Annotations | Extendable via Dmp\LoggableBundle\Annotation\Loggable trait. |
| CI/CD | Add to composer.json; no build step required (annotations are compile-time). |
Service methods at INFO level").@Loggable usage and log analysis (e.g., Kibana, ELK).dmp/loggable-bundle for breaking changes (low risk; follows Symfony conventions).symfony/dependency-injection, proxy-manager are compatible.@Loggable.config/logging.php.SingleHandler) don’t fill disk space.grep, laravel-log-viewer, or ELK to query @Loggable logs.sentry or bugsnag for alerts.LoggableBundle is registered in bundles.php.@Loggable usage patterns (e.g., "Always log Repository methods").laravel-queue + log:work).memory_get_usage().Monolog\Handler\AsyncHandler) to avoid blocking.Monolog\Processor\UidProcessor to sample logs in prod (e.g., 1% of requests).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| AOP Proxy Generation Fails | Class methods return null |
Fallback to manual logging. |
| Log Volume Explosion | Disk full, app crashes | Set |
How can I help you explore Laravel packages today?