- Can I use this bundle directly in Laravel without Symfony, or is it strictly for Symfony projects?
- This bundle is designed for Symfony and relies on Symfony’s `ContainerInterface` and `Security` components. While it can work with Laravel’s Monolog setup, you’ll need to mock or replace Symfony-specific services (e.g., `auth()`) with Laravel equivalents like `auth()->id()` or create a wrapper class. The nullable service fix in v7.2.0 may help reduce errors, but core Symfony dependencies remain.
- What Laravel versions does this bundle support, and are there known compatibility issues?
- The bundle itself doesn’t enforce Laravel version constraints, but it requires Symfony components like `symfony/security-core` and `symfony/dependency-injection`. Laravel 8.x/9.x/10.x should work if you handle Symfony dependencies manually, but the bundle hasn’t been tested specifically for Laravel. The nullable service fix in v7.2.0 is defensive but doesn’t address Laravel’s DI container differences.
- How do I configure this bundle to add request IDs or user IDs to Laravel logs?
- Configure the bundle in `config/packages/deamon_logger_extra.yml` to specify handlers (e.g., `main`) and application metadata like `name`, `version`, or `locale`. For Laravel-specific context (e.g., request IDs), override the bundle’s `ExtraContextProcessor` to use Laravel’s `request()->id` or `auth()->id()` instead of Symfony’s `Security` component. Example: Replace `$container->get('security.token_storage')` with `auth()->user()`.
- Will this bundle slow down my Laravel application? Are there performance concerns?
- The nullable service fix in v7.2.0 is a defensive programming change and shouldn’t introduce performance overhead. However, if you’re using Symfony’s `ContainerInterface` directly, Laravel’s container resolution (e.g., `app()->bound()` checks) could add minor conditional overhead. Test with a benchmark to compare logging speed with/without the bundle, focusing on hot paths where Monolog processors run.
- Does this bundle work with Laravel’s default Monolog setup (no Symfony installed)?
- No, the bundle requires Symfony components like `symfony/monolog-bridge` and `symfony/dependency-injection`. If you don’t want to install Symfony, you’ll need to fork the bundle and replace all Symfony-specific logic (e.g., `ContainerInterface`, `UserInterface`) with Laravel equivalents. The nullable service fix helps avoid errors, but core dependencies remain Symfony-centric.
- How do I handle missing services in Laravel if this bundle tries to access Symfony’s container?
- Use Laravel’s `app()->bound('service') ? app('service') : null` pattern to safely check for services. For example, if the bundle’s `ExtraContextProcessor` fails when a service is missing, wrap its calls in a null-safe block. Alternatively, create a custom processor that uses Laravel’s `auth()`, `request()`, or `app()` methods directly instead of relying on Symfony’s container.
- Are there alternatives to this bundle for Laravel that don’t require Symfony dependencies?
- Yes. For Laravel, consider `spatie/laravel-logging` or custom Monolog processors using Laravel’s built-in helpers like `Log::withContext(['user_id' => auth()->id()])`. Packages like `laravel-debugbar/debugbar` also provide logging context tools. If you need Symfony-like context injection, a lightweight fork of this bundle (replacing `ContainerInterface` with Laravel’s `Container`) could work, but it’s not officially supported.
- How do I test this bundle in a Laravel project before production use?
- Start by installing the bundle in a fresh Laravel project and configure it minimally in `deamon_logger_extra.yml`. Log a test message and verify no errors occur. Use a custom Monolog processor to intercept and log context data, ensuring it works with Laravel’s `auth()` and `request()` methods. Check for silent failures (e.g., missing services) by enabling debug logging and inspecting the output for warnings or null values.
- What’s the maintenance status of this bundle? Should I fork it for Laravel use?
- The bundle has low activity (e.g., one PR in 6 months) and is primarily maintained for Symfony. The nullable service fix in v7.2.0 shows minor updates, but no Laravel-specific tests or commits exist. If you need active maintenance, consider forking it and replacing Symfony dependencies with Laravel equivalents. Alternatively, use a community-maintained fork or build a custom solution.
- Can I use this bundle alongside Laravel’s built-in logging (e.g., `Log::info()`) without conflicts?
- Yes, but you’ll need to configure the bundle to target specific Monolog handlers (e.g., `main`) in `deamon_logger_extra.yml`. Ensure your Laravel logging channels (e.g., `stack`, `single`) align with the bundle’s configured handlers. The bundle won’t override Laravel’s `Log` facade directly but will inject context into Monolog records processed by its handlers. Test with mixed logging (e.g., `Log::info()` and `logger->info()`) to confirm behavior.