#ZF2 PHP Resque Worker in zf2
Dependency
- redis server
- 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
-
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.
<pre>
$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);
}
</pre>
otherwise skip this .