basebuilder / scheduling
CRON like behaviour with PHP. You can replace many cron jobs with a single entry when using this
Installs: 12 841
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 11
Forks: 0
Open Issues: 0
Requires
- php: ~5.5|~7.0
- mtdowling/cron-expression: 1.1.*
- nesbot/carbon: 1.21.*
- symfony/process: 3.*
- webmozart/assert: 1.1.*
Requires (Dev)
- phpunit/phpunit: ~4.5
Suggests
- symfony/console: When you want to use the console commands
This package is not auto-updated.
Last update: 2022-08-20 07:50:11 UTC
README
basebuilder/scheduling replicates CRON behaviour in PHP.
Install
Via Composer
$ composer require basebuilder/scheduling
Usage
Let's say you create /var/php/cron.php
with the following contents:
<?php // load autoloader require_once(__DIR__ . '/vendor/autoload.php'); // Define your schedule $schedule = new \Basebuilder\Scheduling\Schedule(); $schedule ->run('echo "hello world"') ->everyFiveMinutes(); // run all commands that need to be ran foreach ($schedule->dueEvents() as $event) { $event->run(); }
You can now easily add a single entry to the crontab:
* * * * * /path/to/php /var/php/cron.php
Other scheduling types
The Schedule
can also run a PHP callables:
$schedule ->run(function () { echo "hello world from a function"; }) ->daily();
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email :author_email instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.