{"id":17169057,"url":"https://github.com/vikkio88/mashtru","last_synced_at":"2025-07-23T19:34:32.920Z","repository":{"id":57078009,"uuid":"81014062","full_name":"vikkio88/mashtru","owner":"vikkio88","description":"mashtru shared hosting limited scheduled task capabilities","archived":false,"fork":false,"pushed_at":"2017-03-08T21:45:11.000Z","size":38,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T18:50:12.446Z","etag":null,"topics":["framework-agnostic","php","scheduled-job","scheduled-tasks","shared-hosting"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vikkio88.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-05T18:50:48.000Z","updated_at":"2017-02-06T21:56:05.000Z","dependencies_parsed_at":"2022-08-24T13:00:21.724Z","dependency_job_id":null,"html_url":"https://github.com/vikkio88/mashtru","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/vikkio88/mashtru","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikkio88%2Fmashtru","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikkio88%2Fmashtru/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikkio88%2Fmashtru/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikkio88%2Fmashtru/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vikkio88","download_url":"https://codeload.github.com/vikkio88/mashtru/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikkio88%2Fmashtru/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266738347,"owners_count":23976417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework-agnostic","php","scheduled-job","scheduled-tasks","shared-hosting"],"created_at":"2024-10-14T23:24:50.358Z","updated_at":"2025-07-23T19:34:32.895Z","avatar_url":"https://github.com/vikkio88.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mashtru\n[![Build Status](https://travis-ci.org/vikkio88/mashtru.svg?branch=master)](https://travis-ci.org/vikkio88/mashtru)\n\n**mashtru** will manage scheduled task on shared hosting (and everywhere else really)\n\n## Problem\nShared 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](https://en.wikipedia.org/wiki/Single_responsibility_principle), you will just need to **mashtru**.\n \n## Hook script\nSet the only scheduled task to be the ```hook.php``` script, which will be something like this\n```php\n\u003c?php\nrequire '../vendor/autoload.php';\n\nuse Mashtru\\JobManager;\nuse Mashtru\\Libs\\Helpers\\DBConfig;\nuse Mashtru\\Libs\\Helpers\\RunnerConfig;\n\n$jobs = new JobManager(\n    new DBConfig(\n        'localhost',\n        'mashtru',\n        'root',\n        'root'\n    ),\n    new RunnerConfig(\n        [\n            'App\\Scripts\\\\'\n        ]\n    )\n);\n\n$jobs-\u003efire();\n```\n\nand imagine to have a job si defined in the file ```DosomeStuff.php```\n\n```php\n\u003c?php\n\nnamespace App\\Scripts;\n\nuse Mashtru\\Libs\\Interfaces\\Job;\n\nclass DoSomeStuff implements Job\n{\n\n    public function fire(array $parameters = [])\n    {\n\n        echo \"I do some cron stuff!\";\n        //SOME STUFF\n\n\n        //RETURN AN INT\n        return 0;\n    }\n\n    public function getName()\n    {\n        return 'DoSomeStuff';\n    }\n}\n```\n\nThe fire method of this class will be called how many times you defined it in the Job configuration.\n\n\n## Configure Jobs\n**mashtru** uses a single table called ```mashtru_jobs```, there the structure is as follows\n```sql\nCREATE TABLE mashtru_jobs(\n    id SMALLINT NOT NULL AUTO_INCREMENT,\n    name VARCHAR(255),\n    class_name VARCHAR(255) DEFAULT NULL,\n    args TEXT DEFAULT NULL,\n    delta_minutes INT DEFAULT NULL,\n    active BOOL DEFAULT 1,\n    fire_time TIMESTAMP NULL DEFAULT NULL,\n    updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(),\n    created_at TIMESTAMP NOT NULL,\n    PRIMARY KEY(id),\n    INDEX `name` (`name`)\n);\n```\n column | description \n--- | --- \n**id** | the incremental id for the job\n**name** | the job name (used to identify a job)\n**args** | a text field that will be passed into the fire function (I would cast it with ```json_decode``` as config param)\n**class_name** | the name of the class which ```fire()``` method will be called\n**delta_minutes** | the difference on minutes of the iteration for this job (it will be executed every *delta_minutes* minutes)\n**priority** | a *TINYINT* value which jobs will be order by with ```DESC``` direction (0 by default) (from *-128* to *127*)\n**active** | whether or not the job is active\n**fire_time** | calculated column that will tell mashtru whether the job is ready to be fired or not\n\n\nThe class ```JobManager``` offers utility to install/uninstall/add/delete/update/get jobs from this table. The implementeation of those action is delegated to the library user.\nI will use it within a protected rest-api i.e. so I would be able to set manage the jobs using a rest-api.\n\n## Collabs\nThis is a silly lib that I wrote for me, every help of feedback is well appreciated.\n\n# ToDos\n\n - Make table_name configurable\n - Replace ```delta_minutes``` with cronjob-like configuration\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvikkio88%2Fmashtru","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvikkio88%2Fmashtru","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvikkio88%2Fmashtru/lists"}