Skip to content

gregorip02/laravel-lambda

Repository files navigation

This application contains an example of how to deploy Laravel 8.x as a lambda function in aws. The resources that you will create in your aws account after run serverless deploy are the following.

  • Laravel Function.
  • Artisan Function.
  • HTTP entry point using AWS API Gateway.

Prerequisites

Get started

  1. Clone the repository and configure it.
# Clone this project
git clone --depth 1 https://github.com/gregorip02/laravel-lambda.git

cd laravel-lambda

# Setup environment file
cp .env.example .env

# Generate an application key and copy it to your environment variables file.
echo "base64:$(openssl rand -base64 32)"

# Paste the output in .env file
# APP_KEY=base64:e4IiYMsTe+n+NZMjgPZyCL4kKWJ2y0itnYGqk2ZBJ7c=
  1. Configure your serverless credentials using:
npx serverless config credentials --provider aws --key YOUR-AWS-KEY --secret YOUR-AWS-SECRET -o
  1. Deploy.

By default the deployment of the app is in production mode, before executing the deployment it is optimized to add caching to the aws lambda execution environment by adding cache to the configuration and paths of your application.

See app/Console/Commands/ServerlessOptimizeCommand.php.

make deploy

You can find more documentation on the official brefphp page.

Run npx serverless remove to destroy the stack.

TODO

  • Add support for SQS.
  • Add support for Elastic Cache.
  • Add support for Schedule Commands.

About

Running Laravel as a serverless application powered by @brefphp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages