Hlacos / joboquent by Hlacos

Simple bundle to store queued jobs statuses and history.
17
0
2
Package Data
Maintainer Username: Hlacos
Maintainer Contact: heiszmann@hlacos.hu (Heiszmann László)
Package Create Date: 2014-10-02
Package Last Update: 2014-10-06
Language: PHP
License: MIT
Last Refreshed: 2024-12-22 03:08:42
Package Statistics
Total Downloads: 17
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Joboquent

Eloquent based Jobs for Laravel

It's under development, not recommended for production use!

Install steps

  1. add bundle to composer: "hlacos/joboquent": "dev-master"
  2. composer install
  3. add service provider to the providers list: 'Hlacos\Joboquent\JoboquentServiceProvider'
  4. php artisan migrate --package="hlacos/joboquent"
  5. php artisan db:seed --class="Hlacos\Joboquent\JobStatusTableSeeder"

Usage

Create new job and run it

Tipically it creates in the controller.

The string parameter of the run method is the class name of the Worker in the next step.

Extended JobModel

Feel free to extend this model, just read the extended model section in the worker.

Create worker

Extend Job to make your own working code

Worker use extended JobModel

Only override the $jobModelClass public attribute name to the Extended class name.

Callbacks

  1. beforeStart: runs before the work method. You can initialize data or clean up database...
  2. beforeEnd: runs before the queue job deleted. You can touch related models timestamps or move created files to their public folder...

Set the current percent

Tipically used in the work method in a cycle.

Related models

You can set polimorphic relation to the JobModel.

Don't forget to save related model to the jobModel before it runs.

TODO

  1. Refactoring / code cleaning.