Developing Serverless Functions in Laravel
In this CreatorSeries, we cover how to develop serverless functions with Laravel, using a package called Sidecar. Serverless functions let you tap into the power of AWS Lambda, but without the complexity of setting up a new repo, deployment process, or API Gateway.
You'll learn how to package, deploy, and execute these functions... all from your Laravel application!
Progress
Series Info
- Episodes
- 17
- Run Time
- 1h 41m
- Difficulty
- Advanced
- Last Updated
- Jul 27, 2022
- Version
- Latest
Series Episodes
- Episodes (17)
Introduction
Let's talk about the concept of "serverless," and how we can use serverless functions in our Laravel applications. You may be familiar with the concept from Vapor, but what we're up to is slightly different. Instead of entire applications, we'll be deploying single functions.Configuration
You can always set up AWS credentials manually, but by using Sidecar's `configure` command, we'll have them set up in just a few minutes.Deploy a Node Function
Let's deploy and execute our first Hello World function! We'll cover the creation, packing, and execution of this function, all from Laravel.Deploy a Python Function
Most of us are familiar with Node, but we can deploy many different kinds of functions to Lambda. Here we'll deploy a Python function, just to see how it's done.Browser Automation
Moving past the basics, we'll learn how to control headless Chrome on Lambda. We have full control of the browser, but we don't have to host it ourselves!A Performance Trick
Making sure our functions run as quickly as possible is vital. Here we'll take advantage of the architecture of Lambda to speed up our function handler.Adding Layers
Layers let us add functionality to our Lambda without having to package it into our code. In this video, we'll use a layer to add Chrome to our Lamba.Serverless Browsershot
Laravel developers are probably familiar with Spatie's Browsershot package. We'll use Browsershot on Lambda, with a little help from a package by Stefan Zweifel.Separating by Environment
Your local, staging, and production functions are all kept separate by Sidecar. When several developers are working on a team, Sidecar has a way to make sure you aren't overwriting each other's local functions.Deploying Your Functions
Building on the last video, we learn how to deploy our functions as a part of a deployment process. We look specifically at Envoyer and Vapor, but you can fit Sidecar into any existing process!Environment Variables
Just like your Laravel application needs environment variables, your functions might also need environment variables. Sidecar makes this easy.Executing in Parallel
One of the benefits of Lambda is its massive scalability. Let's figure out how we can take advantage of that ourselves, by executing our functions in parallel instead of sequentially.Async Execution
Promises in PHP? Kind of! Thanks to Guzzle, we can get promise-like behavior and send several requests at once.Fire-and-Forget Execution
If you don't need the response from your function, it doesn't make sense to wait around for it to come back. Executing the function as an "event" takes care of that for us.Warming
Lambda is somewhat infamous for its "cold boot" problems. We can mitigate that a bit by "warming" our functions before they are activated.Debugging
Everything doesn't always go as planned, and when it doesn't, it's nice to have a few debugging tools at your disposal.Goodbye and Next Steps
Thanks so much for following along with this series! But there's still more to learn about Sidecar and serverless functions. Let's wrap up by reviewing some resources you might consider!
