To use Amazon SQS as the queue driver in Laravel, you need to follow these steps:
Install the AWS SDK for PHP: Install the AWS SDK for PHP using Composer by running the command composer require aws/aws-sdk-php
.
Configure the AWS credentials: Set up your AWS credentials by updating the config/aws.php
file or by adding the following environment variables:
Update the config/queue.php
file: Open the config/queue.php
file and set the driver to sqs
. Make sure to also fill in the key
, secret
, queue
, and region
values as per your AWS SQS configuration.
'default' => env('QUEUE_CONNECTION', 'sqs'),
'connections' => [
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'your-queue-name'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
],
.env
file and update the QUEUE_CONNECTION
value to sqs
.QUEUE_CONNECTION=sqs
php artisan queue:work
or by setting up a queue listener in your server configuration.Now, Laravel will use Amazon SQS as the queue driver, and you can push jobs onto the SQS queue using Laravel's queue API.