- How do I install soyuka/pmu in a Laravel project to monitor PHP-FPM?
- Install via Composer with `composer require soyuka/pmu`, then configure it in your Laravel app’s `config/app.php` or via environment variables. The package integrates with PHP-FPM’s status endpoint to fetch metrics like active requests, idle processes, and slow queries.
- Does soyuka/pmu work with Laravel’s default PHP-FPM setup, or do I need custom configuration?
- It works out-of-the-box with standard PHP-FPM setups. Ensure your `php-fpm.conf` or pool config has `pm.status_path` enabled (e.g., `/status`). No Laravel-specific tweaks are needed unless you’re using a non-standard FPM configuration.
- Can I use soyuka/pmu to expose PHP-FPM metrics to Prometheus or Grafana?
- Yes. The package provides structured JSON endpoints for metrics, which you can scrape with Prometheus using its `HTTP` exporter. For Grafana, import a JSON dashboard template or create custom panels for FPM stats like `pm.max_children` or `slow_requests`.
- Will soyuka/pmu slow down my Laravel application during production?
- No, the package is lightweight and only queries the PHP-FPM status endpoint periodically. Metrics are cached and served via Laravel’s routing layer without blocking application requests. Benchmark in staging to confirm minimal overhead.
- Does soyuka/pmu support Laravel 10, 9, or older versions? What’s the minimum PHP version?
- It supports Laravel 9+ and PHP 8.0+. Check the package’s `composer.json` for exact version constraints. For older Laravel versions, ensure your PHP-FPM setup meets the minimum requirements (e.g., `pm.status_path` support).
- How do I secure the PHP-FPM status endpoint if soyuka/pmu exposes it publicly?
- Restrict access via PHP-FPM’s `pm.status_path` configuration. Use Apache/Nginx rules to limit IPs or integrate with Laravel middleware (e.g., `auth:sanctum`) if metrics are served via Laravel routes. Avoid exposing `/status` without authentication.
- Can soyuka/pmu help debug slow PHP-FPM processes in Laravel?
- Yes. The package logs slow requests (configurable threshold) and provides metrics like `slow_requests` and `requests_slow`. Use these to correlate with Laravel logs (e.g., `log:read`) to identify bottlenecks in your application or FPM workers.
- Is there a way to integrate soyuka/pmu with Laravel’s Horizon or queues?
- Indirectly. While pmu focuses on FPM metrics, you can cross-reference slow requests with Horizon job failures or queue delays. For example, a spike in `slow_requests` might indicate blocked queue workers. Use Laravel’s `queue:failed` table for deeper analysis.
- What alternatives exist for monitoring PHP-FPM in Laravel if soyuka/pmu doesn’t fit?
- Consider `php-fpm-exporter` (Prometheus), `netdata` (real-time dashboard), or Laravel-specific tools like `spatie/laravel-monitoring`. For observability, combine FPM metrics with Laravel’s `laravel-debugbar` or `spatie/laravel-logging` for full-stack visibility.
- How do I test soyuka/pmu locally without affecting production PHP-FPM?
- Use a local PHP-FPM pool (e.g., Docker or `php-fpm -y /path/to/pool.conf`) and point pmu to its `status_path`. Mock the FPM status endpoint in tests with Laravel’s `Http::fake()` or a local HTTP server. Avoid testing against production pools.