lucassaraiva5 / queue-bundle
Symfony Queue Bundle
Installs: 74
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Type:symfony-bundle
Requires
- php: >=5.6
- symfony-bundles/bundle-dependency: ^1.0
- symfony-bundles/redis-bundle: ^2.1
Requires (Dev)
- phpunit/php-code-coverage: ^3.3.0|^4.0
- phpunit/phpunit: ^5.3
This package is auto-updated.
Last update: 2025-03-11 15:28:03 UTC
README
Installation
- Require the bundle with composer:
composer require lucassaraiva5/queue-bundle
- Enable the bundle in the kernel:
public function registerBundles() { $bundles = [ // ... new lucassaraiva5\QueueBundle\SymfonyBundlesQueueBundle(), // ... ]; ... }
- Configure the queue bundle in your services.yaml.
Defaults configuration:
ls5_queue: public: true class: lucassaraiva5\QueueBundle\Service\Queue arguments: $storage: '@sb_redis.default'
- Configure the redis client in your config.yml. Read more about RedisBundle configuration.
How to use
A simple example of the use of the queue:
$queue = $this->get('ls5_queue'); // get the service // adding some data to queue $queue->push('User "demo" registered'); $queue->push(1234567890); $queue->push(new \stdClass); // get count of items from queue $queue->count(); // returns integer: 3
// now, we can get the data at any time in the queue order // get data from queue $queue->pop(); // returns string: User "demo" registered $queue->count(); // returns integer: 2 $queue->pop(); // returns integer: 1234567890 $queue->count(); // returns integer: 1 $queue->pop(); // returns object: object(stdClass) $queue->count(); // returns integer: 0
If you want to change the queue:
// adding data to queue `notifications`
$queue->setName('application:notifications');
$queue->push('You have a new message from Jessica');
// adding data to queue `settings`
$queue->setName('account:settings');
$queue->push('User with ID 123 changed password');
// adding data to default queue
$queue->setName('queue:default');
$queue->push('To be or not to be');