Download the PHP package creatortsv/scheduler without Composer
On this page you can find all versions of the php package creatortsv/scheduler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download creatortsv/scheduler
More information about creatortsv/scheduler
Files in creatortsv/scheduler
Package scheduler
Short Description Stand-alone package which provides functionality to schedule script execution
License MIT
Informations about the package scheduler
Scheduler
Stand-alone package which provides functionality to schedule script execution.
Installation
Getting Started
It's easy to start using the scheduler.
The example above just registered simple closure function as a job with default cron expression * * * * *
(which means that it will be executed every minute) and run it.
Cron Expression
For complete documentation of the Cron Expression object visit https://github.com/dragonmantank/cron-expression
Each job has its own cron expression object. The register
method of the ScheduleRegistrarInterface
returns a cron expression object with default value * * * * *
. So you can change it after your job had been registered.
Schedule Provider
Sometimes you want to register several jobs that could be grouped by specific logic. In that case Schedule Provider is more useful.
Don't forget to add your provider via scheduler object
Run Scheduler
By default, the Scheduler is running with the current DateTime
object for each job, that means it will create the DateTime
object and each Cron Expression object using the same timestamp determine if it is the time to execute job or not.
But sometimes you need run your schedule on the specific timestamp, testing for example. Use Scheduler::at
method to change default behaviour.
Advanced Usage
Sometimes you may want to control which jobs must be executed in addition of default behaviour. Only one instance of the registered job should be running at the current time, for example.
In that cases you can use Scheduler::boot
method instead of Scheduler::run
. The boot
method returns ScheduleIterator
object, each item is a job instance which must be executed by the given timestamp and each key is cron expression of given job.
Let's imagine that you have some service which determines that job is already being executed
So you can use this service
But there is the best way to do so
And you shouldn't have to worry about if the job has different type of callable object