arrounded / queues
A set of queue helpers
Requires
- php: >=5.5.9
- illuminate/contracts: ^5.1
- illuminate/queue: ^5.1
- illuminate/support: ^5.1
Requires (Dev)
- fabpot/php-cs-fixer: 2.0.*@dev
- mockery/mockery: ^0.9.4
- phpspec/phpspec: ^2.2
- phpunit/phpunit: ^4.7
- symfony/var-dumper: ^2.7
This package is auto-updated.
Last update: 2019-11-15 14:49:10 UTC
README
An optionated helper for dealing with queues
Install
Via Composer
$ composer require arrounded/queues
A Laravel 4.2 version also availabe: composer require arrounded/queues:dev-laravel/4.2
Usage
First add the module's service provider and facade to config/app.php:
Arrounded\Queues\ServiceProvider::class
'Queues' => Arrounded\Queues\Facades\Queues::class,
Now you can start using the helper in your application code via the Facade:
Pushing jobs
Queues::on('foo')->uses(Foobar::class)->push()
This will push a job on the local_foo_normal
queue.
Priorities
Queues::on('foo')->uses(Foobar::class)->priority(Queues::PRIORITY_HIGH)->push();
This will push a job on the local_foo_high
queue.
Passing a payload
Queues::on('foo')->uses(Foobar::class)->with([ 'bar' => 'foo' ])->push();
This will push a job on the local_foo_normal
queue with a {'bar': 'foo'}
payload
Delaying execution
Queues::on('foo')->uses(Foobar::class)->delay(10)->push();
This will delay the execution of the job by 10 seconds.
Prefixing queue names
The default behavior is to prefix all queues with the current app environment. If you want to overwrite this default on an application level, you can do it in your own ServiceProvider:
$this->app['queues']->setPrefix('foobar') // foobar_foo_normal
Disabling queueing
In some cases you might want to disable queueing all together (for example during integration/functional tests)
// To disable $this->app['queues']->disabled() // To re-enable $this->app['queues']->disabled(false)
Dependency Injection
You can also use dependency injection:
use Arrounded\Queues\Queues; class FooService { public function __construct(Queues $queues) { $this->queues = $queues; }
Testing
$ composer test
License
The MIT License (MIT). Please see License File for more information.