Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GhaithAli's avatar

How to use AWS Elastic beanstalk worker with Laravel app.

Hello everyone, I am trying to deploy a laravel application to my Elastic beanstalk worker environment, which will handle my AWS SQS messages. I am using a laravel application as a web application which sends messages to the AWS SQS and a worker which will poll messages from the SQS. The worker should handle resources extensive events such as sending emails and so on.

My main problem is that I am getting a 500 error when trying to route the request to my local function.

I followed the following video as a guide.

https://www.youtube.com/watch?v=jSVY-SVcCAM&t=

My web.php looks the following:

Route::post('/call-worker',['uses'=>'WorkerController@callWorker']);

and my WorkerController


<?php

namespace App\Http\Controllers;

use Log;
use Mail;
use Request;
use stdClass;



class WorkerController extends Controller
{

public function callWorker(){
        Log::info('This is called!');
        $x = new stdClass();
        $x->id = 1;
        $y= new \stdClass();
        $y->name = 'test';
        $y->id = 0;
        Mail::send('auth.mail.report',['report'=>$x,'currentUser'=> $y], function($message){
            $message->from('[email protected]');
            $message->to('[email protected]')->subject("This post has been reported.");
        });

    }
}
}

And on AWS Elastic beanstalk worker I set the following configurations:

HTTP path: /call-worker
Document root: /laravel/public

Is there any guide on how this could be done in Laravel? I tried searching around in the net but no luck.

Thanks a lot for the help :)

0 likes
1 reply

Please or to participate in this conversation.