1. Go to this page and download the library: Download sidigi/laravel-plain-sqs 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/ */
sidigi / laravel-plain-sqs example snippets
// Add in your config/app.php
'providers' => [
'...',
'Dusterio\PlainSqs\Integrations\LaravelServiceProvider',
];
// Add in your bootstrap/app.php
$app->loadComponent('queue', 'Dusterio\PlainSqs\Integrations\LumenServiceProvider');
// Generate standard config file (Laravel only)
php artisan vendor:publish
// In Lumen, create it manually (see example below) and load it in bootstrap/app.php
$app->configure('sqs-plain');
use Dusterio\PlainSqs\Jobs\DispatcherJob;
class ExampleController extends Controller
{
public function index()
{
// Create a PHP object
$object = [
'music' => 'M.I.A. - Bad girls',
'time' => time()
];
// Pass it to dispatcher job
$job = new DispatcherJob($object);
// Dispatch the job as you normally would
// By default, your data will be encapsulated in 'data' and 'job' field will be added
$this->dispatch($job);
// If you wish to submit a true plain JSON, add setPlain()
$this->dispatch($job->setPlain());
}
}
use Illuminate\Contracts\Queue\Job as LaravelJob;
class HandlerJob extends Job
{
protected $data;
/**
* @param LaravelJob $job
* @param array $data
*/
public function handle(LaravelJob $job, array $data)
{
// This is incoming JSON payload, already decoded to an array
var_dump($data);
// Raw JSON payload from SQS, if necessary
var_dump($job->getRawBody());
}
}
QUEUE_DRIVER=sqs-plain
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.