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:
- No servers to manage – AWS scales automatically from zero to thousands of concurrent requests.
- Pay per request – you are only charged while your code is actually running (AWS includes ~1 M free requests/month).
- Tiny cold starts – Laravel on Bref typically adds only 300–800 ms on the very first invocation.
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 |