1. Go to this page and download the library: Download setono/cron-builder 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/ */
setono / cron-builder example snippets
# etc/cronjobs/jobs.php
declare(strict_types=1);
use Setono\CronBuilder\Context;
use Setono\CronBuilder\CronJob;
return static function (Context $context): iterable {
yield new CronJob('0 0 * * *', '/usr/bin/php {{ release_path }}/send-report.php {{ args|join(" ") }}', 'Run every day at midnight');
if ($context->get('env') === 'prod') {
yield new CronJob('0 0 * * *', '/usr/bin/php {{ release_path }}/process.php {{ args|join(" ") }}');
}
};
use Setono\CronBuilder\CronBuilder;
use Symfony\Component\Finder\Finder;
echo (new CronBuilder())
->addFiles(
(new Finder())
->files()
->in(__DIR__ . '/etc/cronjobs')
->name('*.php')
)
->addContext('release_path', '/home/johndoe/public_html')
->addContext('env', 'prod')
->addContext('args', ['--verbose'])
->build()
;
text
###> Automatically generated by Setono Cron Builder - DO NOT EDIT ###
0 0 * * * /usr/bin/php /home/johndoe/public_html/send-report.php --verbose # Run every day at midnight
0 0 * * * /usr/bin/php /home/johndoe/public_html/process.php --verbose
###< Automatically generated by Setono Cron Builder - DO NOT EDIT ###
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.