This bundle brings scheduling to your BernardPHP powered Symfony2 app.
Please note that this bundle relies on redis as backend.
-
Add BernardSchedulerBundle to your dependencies:
// composer.json { // ... "require": { // ... "pompdelux/bernard-scheduler-bundle": "1.*" } }
-
Use Composer to download and install the bundle:
$ php composer.phar update pompdelux/bernard-scheduler-bundle
-
Register the bundle in your application:
// app/AppKernel.php class AppKernel extends Kernel { // ... public function registerBundles() { $bundles = array( // ... new Pompdelux\BernardSchedulerBundle\BernardSchedulerBundle(), ); } }
-
Add
php_redis
section toconfig.yml
// app/config.yml php_resque: class: bernard: host: %redis_host% port: %redis_port% prefix: %redis_prefix% skip_env: %redis_skip_env% database: %redis_database% auth: %redis_password%
use Pompdelux\BernardSchedulerBundle\Job;
// Adds 'DoStuff' job to 'some-bernard-queue' for execution in 30 seconds.
$job = new Job('some-bernard-queue', 'DoStuff', [
'any' => 'job data',
]);
$container->get('pdl.bernard_scheduler')->enqueueIn(30, $job);