Download the PHP package vikkio88/mashtru without Composer
On this page you can find all versions of the php package vikkio88/mashtru. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vikkio88/mashtru
More information about vikkio88/mashtru
Files in vikkio88/mashtru
Package mashtru
Short Description A framework-agnostic php library usefull to manage scheduled tasks on shared webhosting or not
License MIT
Informations about the package mashtru
mashtru
mashtru will manage scheduled task on shared hosting (and everywhere else really)
Problem
Shared php web hosting, usually give you a limited number of scheduled task script (from 1 to 5), and if you need you app to perform some async cron jobs, and you dont want to forget about single responsibility principle, you will just need to mashtru.
Hook script
Set the only scheduled task to be the script, which will be something like this
and imagine to have a job si defined in the file
The fire method of this class will be called how many times you defined it in the Job configuration.
Configure Jobs
mashtru uses a single table called , there the structure is as follows
column | description |
---|---|
id | the incremental id for the job |
name | the job name (used to identify a job) |
args | a text field that will be passed into the fire function (I would cast it with as config param) |
class_name | the name of the class which method will be called |
delta_minutes | the difference on minutes of the iteration for this job (it will be executed every delta_minutes minutes) |
priority | a TINYINT value which jobs will be order by with direction (0 by default) (from -128 to 127) |
active | whether or not the job is active |
fire_time | calculated column that will tell mashtru whether the job is ready to be fired or not |
The class offers utility to install/uninstall/add/delete/update/get jobs from this table. The implementeation of those action is delegated to the library user. I will use it within a protected rest-api i.e. so I would be able to set manage the jobs using a rest-api.
Collabs
This is a silly lib that I wrote for me, every help of feedback is well appreciated.
ToDos
- Make table_name configurable
- Replace with cronjob-like configuration