Serverless Laravel AWS Lambda Guide

How to install Laravel in a serverless architecture (AWS Lambda)

As you already know, serverless has definitely become a hype in the last few years, managing servers is a thing of the past, but what happens when you have all your code in a solid MVC Framework like Laravel, can’t switch to nodejs but still want to use this amazing AWS Feature?

You do your Google search and find this guide 😆! For those who don’t know, Taylor Otwell created Laravel Vapor for $39.99/mo! quite cool but we will perform almost everything he does for free in this guide.

Architecture


Here’s a brief architecture on what we will be building:

Laravel AWS Lambda Serverless

Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with low latency, high transfer speeds, all within a developer-friendly environment.

reference: https://aws.amazon.com/cloudfront/

Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. APIs act as the “front door” for applications to access data, business logic, or functionality from your backend services. Using API Gateway, you can create RESTful APIs and WebSocket APIs that enable real-time two-way communication applications. API Gateway supports containerized and serverless workloads, as well as web applications.

reference: https://aws.amazon.com/api-gateway/

Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.

reference: https://aws.amazon.com/s3/

AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume.

With Lambda, you can run code for virtually any type of application or backend service – all with zero administration.

reference: https://aws.amazon.com/lambda/

Step 1 – Install Laravel & Install Bref


I will assume you already know how to download a copy of Laravel, and you already have it up & running in your local environment.

In case you are starting a new Laravel application you can clone it from here.

git clone https://github.com/crsurfer/serverless-laravel

If you already have a laravel project you can check the serverless.yaml file here.

Recent Post