Download the PHP package phpnomad/tasks without Composer
On this page you can find all versions of the php package phpnomad/tasks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package tasks
phpnomad/tasks
phpnomad/tasks provides interfaces for declaring background and scheduled tasks in PHP applications. A task is a serializable value object with a stable id and a toPayload() / fromPayload() round trip, which means you can dispatch one now and let a worker, a queue, or the platform's scheduler reconstruct it and run it later.
The dispatching strategy is pluggable. A concrete implementation decides whether a task runs immediately, lands on a Redis queue for a background worker to pick up, or gets registered with the host platform's scheduler (like WordPress cron). Your task classes and their handlers stay the same either way. This package is interfaces only and has zero runtime dependencies. For a working queue, also install a concrete implementation. The recommended one is phpnomad/redis-task-integration, a Redis-backed worker queue. The package is used in production by Siren and other PHPNomad applications.
Installation
For a working queue, also install the Redis integration:
Quick Start
Define a task. It needs a stable identifier and a payload that can survive a trip through JSON.
Write a handler that runs the task. The @implements tag lets your static analyzer narrow $task to the concrete class.
Register the task-to-handler mapping on an initializer so the bootstrapper can wire it up.
Dispatch the task from wherever the work is triggered. Inject TaskStrategy and call dispatch().
The strategy chosen at bootstrap decides whether the task runs immediately, lands on a queue for a worker to pick up, or gets registered with the host scheduler. SendWelcomeEmail and SendWelcomeEmailHandler do not care which.
Key Concepts
Task: serializable value object identified by a staticgetId()string with a round-trip payloadTaskStrategy: the dispatcher interface responsible for running, enqueueing, or scheduling a taskCanHandleTask: the contract a handler implements to process a taskHasTaskHandlers: initializer interface modules implement to register their task-to-handler mappingsIsIdempotent: optional marker for tasks that must not double-run, with a deterministic key and a TTLIdempotencyStore: contract for the backing store that suppresses replays and concurrent double-runs
Documentation
Full documentation for PHPNomad, including the bootstrapping guide and the broader framework reference, lives at phpnomad.com.
License
MIT. See LICENSE.txt.