- What is patchlevel/worker used for?
- patchlevel/worker is a lightweight worker abstraction for Laravel and PHP applications that need long-lived background processes. It helps with clean startup, signal handling, execution limits, and graceful shutdown. Typical uses include custom daemons, queue-like processors, and background tasks that must terminate properly when limits are exceeded.
- How do I install patchlevel/worker in a Laravel app?
- Install the package with Composer using composer require patchlevel/worker. Then integrate its worker abstraction into your long-running command or daemon and configure limits and shutdown behavior for your use case. Check the package README for any service provider, configuration, or publishing steps specific to your version.
- Does patchlevel/worker handle signals and graceful shutdown?
- Yes, the package is designed around clean startup, signal handling, and graceful shutdown for long-running PHP processes. This helps workers respond properly to termination requests instead of being killed abruptly. You should still test shutdown behavior under your process manager and deployment setup.
- Can I use patchlevel/worker for custom daemons and queue-like tasks?
- Yes, it is intended for background processes such as custom daemons and queue-like workers. It provides a lightweight abstraction rather than tying you to Laravel's standard queue workflow. That makes it useful when you need control over startup, limits, signals, and shutdown.
- How do I configure a worker to terminate when limits are exceeded?
- The package is built to help a worker terminate properly when configured limits are exceeded. You define the relevant limits in your worker implementation or configuration and rely on the package's shutdown handling to exit cleanly. Review the README for the exact limit options and expected termination behavior in your version.
- Which Laravel and PHP versions does patchlevel/worker support?
- The provided context does not list specific Laravel or PHP version constraints. Check the package composer.json and README for the supported version matrix before installing. Confirm compatibility with your application's PHP runtime and Laravel release, especially before upgrading either one.
- How should I test workers built with patchlevel/worker?
- Extract your task-handling logic from the worker loop so it can be invoked directly in unit tests. For signal handling, limits, and shutdown, use process-level or integration tests that start and terminate the worker. Keep test limits short so termination paths run quickly and reliably.
- Is patchlevel/worker safe for production long-running processes?
- It is intended for long-lived background processes, but production safety depends on your supervision, logging, and deployment practices. Run workers under a process manager such as Supervisor or systemd and verify graceful shutdown during deploys. Monitor memory usage and restart behavior for your specific workload.
- How does patchlevel/worker compare with Laravel's built-in queue worker?
- Laravel's queue:work command is specialized for processing queue jobs and includes its own lifecycle management. patchlevel/worker is a more general worker abstraction for custom daemons and background loops. Use it when you need explicit control over startup, signals, limits, and shutdown outside the standard queue workflow.
- How do I handle deployments and worker restarts with patchlevel/worker?
- Design workers to exit cleanly when they receive a termination signal so your process manager can restart them during deployments. Make tasks idempotent or checkpoint in-progress work where needed. The package's graceful shutdown support helps reduce abrupt terminations, but your deployment tooling should still allow enough time for workers to finish safely.