# PQueueBundle Integration of [michel/pqueue](https://github.com/michelphp/pqueue) into Symfony. ## Installation ```bash composer require michel/pqueue-bundle ``` ## Configuration Create a configuration file `config/packages/pqueue.yaml`: ```yaml pqueue: transport: class: 'Michel\PQueue\Transport\FilesystemTransport' options: directory: '%kernel.project_dir%/var/pqueue' handlers: # Auto-discovery of handlers in these directories sources: - '%kernel.project_dir%/src/MessageHandler' ``` ## Usage ### 1. Create a Message and Handler First, define a message class: ```php // src/Message/EmailNotification.php namespace App\Message; class EmailNotification { public function __construct( public int $userId ) {} } ``` Then, create a handler for it: ```php // src/MessageHandler/EmailNotificationHandler.php namespace App\MessageHandler; use App\Message\EmailNotification; class EmailNotificationHandler { public function __invoke(EmailNotification $message): void { // Process message for user $message->userId } } ``` *Note: The handler is automatically discovered if it is in one of the configured source directories. It must implement `__invoke` with a single argument type-hinted with the message class.* ### 2. Dispatch a Message Inject `Michel\PQueue\PQueueDispatcher` and send a message: ```php use Michel\PQueue\PQueueDispatcher; use App\Message\EmailNotification; public function index(PQueueDispatcher $dispatcher) { $dispatcher->send(new EmailNotification(123)); } ``` ### 3. Run the Worker ```bash php bin/console pqueue:worker:run ``` ## License This bundle is released under the [MPL-2.0 License](LICENSE).