library zf2-php-resque
PHP Resque Worker in zf2
saurabhaec/zf2-php-resque
PHP Resque Worker in zf2
- Friday, September 11, 2015
- by saurabhaec
- Repository
- 1 Watchers
- 2 Stars
- 6 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 1 Open issues
- 1 Versions
- 0 % Grown
ZF2 PHP Resque Worker in zf2
Dependency, (*1)
-
redis server
Instalation, (*2)
-
move file resquezf2.global.php.dist from config folder to globle config folder and rename file to resquezf2.global.php
-
add Resquezf2 in application.config.php file at moduel section to load this moudle.
-
load Resque Library;
add this line to your module.php
require_once APPLICATION_PATH."/module/Resquezf2/src/Resquezf2/vendor/autoload.php";
-
if you are useing BjyAuthorize moduel then add this line to your moduel.php to desable its for commond line rout
$request = $e->getTarget()->getServiceManager()->get('Request');
if ($request instanceof ConsoleRequest) {
//throw new RuntimeException('You can only use this action from a console!');
// console desable BjyAuthorize
}else{
//bjyauthorise navigation
$authorize = $e->getTarget()->getServiceManager()->get('BjyAuthorizeServiceAuthorize');
$acl = $authorize->getAcl();
$role = $authorize->getIdentity();
// var_dump($acl , $role); exit();
$parentRoles = $authorize->getIdentityProvider()->getIdentityRoles();
\Zend\View\Helper\Navigation::setDefaultAcl($acl);
\Zend\View\Helper\Navigation::setDefaultRole($role);
}
otherwise skip this .
-
run worker in commond line
php public/index.php run-worker
-
#Add job in queue
\Resque::setBackend('localhost:6379');
$args = array( );
\Resque::enqueue('zf2-php-resque', 'Resquezf2\Model\Job', $args );
-
you can also create your own class in model location.