PHP code example of aurimasniekis / scheduler-bundle
1. Go to this page and download the library: Download aurimasniekis/scheduler-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use AurimasNiekis\SchedulerBundle\ScheduledJobInterface;
class NamelessJob implements ScheduledJobInterface
{
public function __invoke(): void
{
// Execute some logic
}
public function getSchedulerExpresion(): string
{
return '*/5 * * * *'; // Run every 5 minutes
}
}
use AurimasNiekis\SchedulerBundle\NamedScheduledJobInterface;
class NamedJob implements NamedScheduledJobInterface
{
public function __invoke(): void
{
// Execute some logic
}
public function getName(): string
{
return 'named_job';
}
public function getSchedulerExpresion(): string
{
return '*/5 * * * *'; // Run every 5 minutes
}
}
bash
$ bin/console scheduler:list
+------------------------------+-------------+---------- Scheduled Jobs -------------------------------------------------------+
| Name | Expression | Next Scheduled Run Times |
+------------------------------+-------------+---------------------------------------------------------------------------------+
| named_job | */5 * * * * | 2020-03-22T04:55:00+00:00, 2020-03-22T05:00:00+00:00, 2020-03-22T05:05:00+00:00 |
| App\ScheduledJob\NamelessJob | */5 * * * * | 2020-03-22T04:55:00+00:00, 2020-03-22T05:00:00+00:00, 2020-03-22T05:05:00+00:00 |
+------------------------------+-------------+---------------------------------------------------------------------------------+
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.