PHP code example of christoph-kluge / bref-sqs-laravel

1. Go to this page and download the library: Download christoph-kluge/bref-sqs-laravel 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/ */

    

christoph-kluge / bref-sqs-laravel example snippets


#!/opt/bin/php
 declare(strict_types=1);

$appRoot = getenv('LAMBDA_TASK_ROOT');
\Kernel $kernel */
$kernel = app(\Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

$status = $kernel->handle(
    $input = new Symfony\Component\Console\Input\StringInput(getenv('ARTISAN_COMMAND')),
    new Symfony\Component\Console\Output\ConsoleOutput
);

$kernel->terminate($input, $status);

yaml
functions:
  queue:
    handler: artisan.php
    environment:
      ARTISAN_COMMAND: 'sqs:work sqs --tries=3 --sleep=1 --delay=1'
    layers:
      - ${bref:layer.php-81}
    events:
      - sqs:
          arn: arn:aws:sqs:region:XXXXXX:default-queue
          batchSize: 10

  another-queue:
    handler: artisan.php
    environment:
      ARTISAN_COMMAND: 'sqs:work sqs --queue=another-queue --tries=3 --sleep=1 --delay=1'
    layers:
      - ${bref:layer.php-81}
    events:
      - sqs:
          arn: arn:aws:sqs:region:XXXXXX:another-queue
          batchSize: 10