- Can I use this bundle directly in a Laravel project, or is it only for Symfony?
- This bundle is originally designed for Symfony, but Laravel can adopt it with minimal effort. You’ll need to create a Service Provider to bridge Symfony’s EventDispatcher and DependencyInjection with Laravel’s Illuminate equivalents. The core monitoring logic (health checks, status reporting) remains usable.
- What Laravel versions does this bundle support?
- The bundle itself doesn’t enforce Laravel version constraints, but compatibility depends on your adapter layer. Target Laravel 8.x+ for best results, as it aligns closely with Symfony’s event and container systems. Test thoroughly with your specific Laravel version.
- How do I configure health checks for my Laravel services?
- Health checks are defined via configuration (typically YAML/XML in Symfony). For Laravel, publish the config file using `php artisan vendor:publish` (if supported) or manually create a `config/sam.php` file. Define checks under a `health_checks` array with keys like `database`, `queue`, or `external_api`.
- Does this bundle support Prometheus or other monitoring backends?
- The bundle’s backend support depends on its original design. If it outputs metrics in a Prometheus-compatible format, you can integrate it with Laravel using `spatie/laravel-prometheus`. For other backends (e.g., ELK, custom sinks), check if the bundle exposes event listeners or adapters you can extend.
- How do I handle database storage for monitoring events in Laravel?
- If the bundle uses Doctrine, create Eloquent models to map its tables. For example, define a `SamEvent` model pointing to the `sam_events` table. Alternatively, use raw queries if the schema is simple. Ensure your migrations align with the bundle’s expected database structure.
- Will this bundle work with Laravel’s queue system (e.g., Horizon) for async monitoring?
- Yes, but you’ll need to adapt the bundle’s event listeners to dispatch jobs via Laravel’s queue system. Wrap monitoring events in a `dispatch()` call or use a queue listener to process them asynchronously. Test with `php artisan queue:work` to verify async behavior.
- Are there Laravel alternatives to this bundle for monitoring?
- Yes, consider `spatie/laravel-monitoring` for lightweight health checks or `laravel-debugbar/debugbar` for runtime insights. For Prometheus integration, `spatie/laravel-prometheus` is a strong alternative. Evaluate whether you need SAM’s specific features (e.g., structured status reporting) before switching.
- How do I add custom monitoring metrics or alerts to this bundle?
- Extend the bundle by creating custom event listeners or services. For example, dispatch a `sam.event.record` event with your metric data. If the bundle supports plugins, implement a new backend or listener. Document your changes in Laravel’s Service Provider for maintainability.
- What’s the performance impact of using this bundle in production?
- The bundle’s overhead depends on how many health checks and events you configure. Benchmark critical paths (e.g., event listeners, database writes) in your Laravel environment. Optimize by batching writes or using Laravel’s queue system for async processing.
- How do I test this bundle in a Laravel CI pipeline?
- Test the bundle by mocking its dependencies (e.g., EventDispatcher, database). Use Laravel’s `phpunit` to verify health check endpoints and event listeners. Include tests for your adapter layer (e.g., Service Provider bindings) and custom configurations. Example: `php artisan test --filter=SamMonitoringTest`.