- How do I install yzalis/supervisor in a Laravel project?
- Run `composer require yzalis/supervisor` to install the package. No additional Laravel service provider registration is required unless you need container binding. The package provides Artisan commands (e.g., `supervisor:generate`) and a PHP API out of the box.
- Can this package manage Laravel queue workers (e.g., laravel-worker)?
- Yes, it’s a perfect fit for Laravel queue workers. Use the `SupervisorManager` class to generate configs for `laravel-worker`, start/stop/restart processes, and monitor their status. Example: `Supervisor::process('laravel-worker')->restart()`.
- What Laravel versions does yzalis/supervisor support?
- The package requires PHP 8.0+ and is designed for Laravel 8.x and 9.x. For Laravel 10, verify compatibility with the latest release, as Supervisor itself has no Laravel-specific dependencies. Check the package’s `composer.json` for exact PHP version constraints.
- How do I dynamically update Supervisor configs without downtime?
- Use `Supervisor::reload()` to apply config changes without downtime. For dynamic updates (e.g., scaling workers), generate new configs with `Supervisor::generate()` and reload. Ensure your `supervisord.conf` includes the auto-generated configs in the `[include]` directive.
- Does this package work with Docker or Kubernetes deployments?
- Yes, but you’ll need to ensure Supervisor is installed and running inside your container. The package abstracts Supervisor interactions, so it works the same way—just point configs to the correct paths (e.g., Docker volumes for `/etc/supervisor/conf.d/`).
- How can I monitor Supervisor process statuses in Laravel?
- Use `Supervisor::status('process_name')` to check if a process is running. For observability, integrate with Laravel’s logging (Monolog) or monitoring tools like Prometheus by extending the package’s events or writing custom listeners for process state changes.
- What happens if Supervisor crashes or becomes unresponsive?
- The package doesn’t handle Supervisor failures natively, but you can implement fallbacks. For example, use Laravel’s `Process` facade or Symfony’s `Process` component as a backup for critical operations. Log errors via `Supervisor::exception()` and set up alerts for Supervisor downtime.
- Can I use this package for non-Laravel PHP processes (e.g., custom scripts)?
- Absolutely. The package is framework-agnostic for Supervisor interactions. Define your process configs in Laravel’s config files (e.g., `config/supervisor.php`) and use the API to manage any PHP script, including cron jobs, API servers, or background workers.
- How do I test Supervisor interactions in PHPUnit?
- Unit testing is challenging due to Supervisor’s external nature. Use mocks for the `SupervisorManager` interface or create integration tests that verify Artisan commands (e.g., `php artisan supervisor:generate`) produce correct configs. Test edge cases like invalid process names or missing configs.
- What are the alternatives to yzalis/supervisor for Laravel process management?
- For simpler use cases, Laravel’s built-in `Process` facade or Symfony’s `Process` component can run one-off commands. For advanced process management, consider `spatie/laravel-queue-worker` (for queue workers) or custom scripts with `pcntl` for Unix systems. However, none offer Supervisor’s full feature set (e.g., process monitoring, auto-restart).