PHPJOBS

PHP JOBS - Simple Task / Queue Processing

Download .zip Download .tar.gz View on GitHub

Welcome to PHPJOBS Project Home Page

You always wanted to add tasks into a queue and execute the tasks in this queue later independently than the moment you add those ? Then this library is made for you.

With PHPJOBS, you can :

  • Add new tasks composed of single jobs
  • Add new tasks composed of several jobs (job before, job main, job after)
  • Add new scheduled tasks
  • Show the tasks in processing [ShowQueue]
  • Execute the tasks in processing [ExecuteQueue]
  • Force tasks execution [ForceTaskExecution]
  • Show finished tasks [ShowFinishedTasks]

Of course, you can call your own functions by doing a "require" when you execute each task. When the Job is being executed, the function is found and the job can be executed given your functions context.

Installation

  1. Copy phpjobs_*.php files to your root project as well as the phpjobs directory
  2. Watch the phpjobs_add_tasks.php file : all examples are available in this file

Usage

  1. Watch the files at the root of the project first.
  2. Add tasks containing simple jobs. Ex: download a file from a URL.
  3. There are already common functions available for execution : PhpJobs_DownloadFromUrl, PhpJobs_FileCopy, PhpJobs_FileMove, PhpJobs_FileDelete that can help you play with it.
  4. Show the tasks waiting to be processed.
  5. Execute the tasks in the queue independantly.

By exemple :

` <?php require 'req_header.php'; // Contains the function YourFunction($param1, $param2)

require_once 'phpjobs/phpjobs_tasks_manager.php';

$job1 = new Job('PhpJobs_DownloadFromUrl',array('http://www.google.fr/images/srpr/logo11w.png','store/google.png')); PhpJobs_AddTaskToQueue("Download Google logo", PHPJOBS_PRIORITY_NORMAL, $job1);

$job2 = new Job('YourFunction',array('param1,'param2')); PhpJobs_AddTaskToQueue("Call to my function", PHPJOBS_PRIORITY_NORMAL, $job2);

?> `

Feel free to add more features to this library.

Logging

Uses Apache log4php library with rolling files. Ready to use one file per day, or even syslog if needed.

Authors and Contributors

Please full request features or contributions to @jgarino.