dev-master
9999999-dev https://github.com/hosopy/fuel-jobqueueFuelPHP Jobqueue Package
MIT
The Requires
- php >=5.3.3
- composer/installers *
- symfony/process 2.3
- pda/pheanstalk *
queue job fuelphp jobqueue
FuelPHP Jobqueue Package
Jobqueue package for FuelPHP., (*1)
Add required package to your composer.json
., (*2)
... "require": { ... "hosopy/fuel-jobqueue": "dev-master", ... }, ...
And run composer installer., (*3)
$ php composer.phar install
Download zip archive or clone this repository, and extract to fuel/app/packages/fuel-jobqueue
., (*4)
'always_load' => array( 'packages' => array( 'fuel-jobqueue', ...
Copy default configuration file to your app/config directory., (*5)
$ cp fuel/packages/fuel-jobqueue/config/jobqueue.php fuel/app/config
If you want to run beanstalkd in other machine or port, edit configuration., (*6)
For the moment, keep default configuration., (*7)
return array( // default connection name 'default' => 'default_connection', 'connections' => array( 'default_connection' => array( 'driver' => 'beanstalkd', 'host' => '127.0.0.1', 'port' => '11300', 'queue' => 'jobqueue', ), ), );
Currently, fuel-jobqueue uses beanstalkd as a backend of queueing., (*8)
If beanstalkd is not installed in your machine, install it first., (*9)
# Example: homebrew (Mac) $ brew install beanstalkd $ beanstalkd
# Example: Ubuntu $ sudo apt-get install beanstalkd
If you want to know about beanstalkd more, see ., (*10)
Define your job handler class in fuel/app/classes/myjob.php
., (*11)
<?php class Myjob { // [IMPORTANT] Requires 'fire' method as a entry point. public function fire($job, $data) { // heavy job sleep(10); } }
In your controller, call \Jobqueue\Queue::push($job, $data)
to push a new job., (*12)
class Controller_Welcome extends Controller { public function action_index() { // push a new job onto the default queue of the default connection. // 'Myjob' is a class name you have defined. \Jobqueue\Queue::push('Myjob', array('message' => 'Hello World!')); return Response::forge(View::forge('welcome/index')); } ...
Queued jobs cannot be executed untill the worker process pop it from the queue., (*13)
$ cd FUEL_ROOT $ php oil refine jqworker:listen --connection=default_connection --queue=jobqueue
Now, we are ready for queueing!, (*14)
Execute your controller action., (*15)
Sorry under construction..., (*16)
Sorry under construction..., (*17)
Sorry under construction..., (*18)
Sorry under construction..., (*19)
FuelPHP Jobqueue Package
MIT
queue job fuelphp jobqueue