Laravel + Bref on AWS Lambda

What is Bref?

Bref is an open-source toolkit that lets you run PHP on AWS Lambda. It ships a php-fpm Lambda layer that starts a PHP-FPM worker inside the Lambda execution environment, so your existing PHP code — including Laravel — just works.

Key advantages:

Project File Map

File / Directory Purpose
serverless.yml Declares the Lambda function, attaches the Bref FPM layer, sets env vars
layers.js Resolves the correct FPM layer ARN for your AWS region
routes/web.php Laravel route definitions (/ and /about)
app/Http/Controllers/ HomeController & AboutController
resources/views/ Blade templates: shared layout + one per page
public/index.php Laravel's standard entry-point (served by the FPM layer on Lambda)

Useful Commands

Goal Command
Install deps npm install && composer install
Run locally php artisan serve
Deploy (dev stage) npm run deploy:dev
Deploy (prod stage)npm run deploy
Tear down npm run remove