问题描述:

hey guys i am new to redis with php. I am currently working with symfony. I have written a simple form which accept data and send the mail. here is my controller

namespace Ens\NewBundle\Controller;

use Ens\NewBundle\Entity\Product;

use Symfony\Component\HttpFoundation\Request;

use Symfony\Component\Form\FormBuilder;

require '/var/www/predis/autoload.php';

\Predis\Autoloader::register();

require_once('Services/Notification.php');

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller

{

function to be performed on starting.

 public function indexAction()

{

$x=array('to'=>'[email protected]','name'=>'Rohitashv singhal');

$client = new \Predis\Client();

//$client->lpush('email','[email protected]');

//$u=$client->blpop('emailnew',0);

//var_dump($u);

$product=new Product();

$product->setName('rohit');

$product->setPass('rohit');

$form=$this->createFormBuilder($product)

->add('name','text')

->add('pass','password')

->getForm();

$z=notification_on_signup($x);

if($z)

$name='success';

else

$name='failed';

return $this->render('EnsNewBundle:Email:ind.html.twig',

array('form'=>$form->createView(),'name'=>'rohit'));

}

}

here notification_on_signup function is defined in another function which is sending mail. when i am clicking on submit button then i am calling the same function again. what I want is that when I submit the form then the form should come first and the email function notification_on_signup should run in the background. how should i use the redis to send the function in background. please help

网友答案:

If i understand your question correctly, I think this doesn't have anything to do with redis. Instead you have to use a Job Server such as gearman

网友答案:

Maybe this will help you: php-resque is a Redis-backed PHP library for creating background jobs, placing them on multiple queues, and processing them later.

Here is the link: https://github.com/mjphaynes/php-resque

相关阅读:
Top