PHP code example of tavii / sqs-job-queue-bundle
1. Go to this page and download the library: Download tavii/sqs-job-queue-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tavii / sqs-job-queue-bundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Tavii\SQSJobQueueBunblde\SQSJobQueueBundle()
);
// ...
}
// ...
}
// src/AppBundle/Job/SendMailJob.php
namespace AppBundle\Job;
use Tavii\SQSJobQueueBundle\ContainerAwareJob;
class SendMailJob extends ContainerAwareJob
{
public function getName()
{
return 'test'; // ここをキュー名と一致させること
}
public function run()
{
$message = \Swift_Message::newInstance()
->setFrom('[email protected]')
->setTo('[email protected]')
->setSubject('job test')
->setBody('job mail test');
$mailer = $this->getContainer()->get('mailer');
$ret = $mailer->send($message);
return true;
}
}
...
$job = new TestJob();
$this->getContainer()->get('sqs_job_queue.queue')->push($job);