All Projects → hammerstonedev → sidecar

hammerstonedev / sidecar

Licence: MIT license
Deploy and execute AWS Lambda functions from your Laravel application.

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to sidecar

s3-monitoring
No description or website provided.
Stars: ✭ 14 (-97.42%)
Mutual labels:  lambda
lambda-memory-performance-benchmark
Performance and cost benchmark tool for AWS Lambda on memory sizes 📈⏱
Stars: ✭ 60 (-88.95%)
Mutual labels:  lambda
sigs
Simple thread-safe signal/slot C++17 include-only library.
Stars: ✭ 32 (-94.11%)
Mutual labels:  lambda
serverless-graalvm-demo
Sample serverless application written in Java compiled with GraalVM native-image
Stars: ✭ 132 (-75.69%)
Mutual labels:  lambda
aws-backup-lambda
A utility AWS lambda function to manage EBS and RDS snapshot backups.
Stars: ✭ 60 (-88.95%)
Mutual labels:  lambda
serverless-podcast
[UNMAINTAINED] 📢 Easy, cheap podcast hosting using Serverless and S3
Stars: ✭ 15 (-97.24%)
Mutual labels:  lambda
aws-cloudformation-cognito-identity-pool
A Lambda-backed Custom Resource for a Cognito Identity Pool in CloudFormation
Stars: ✭ 35 (-93.55%)
Mutual labels:  lambda
functions.netlify.com
Tutorials, examples, workshops and a playground for serverless with Netlify Functions
Stars: ✭ 498 (-8.29%)
Mutual labels:  lambda
lambda-ci
CI/CD for Lambda Functions with Jenkins
Stars: ✭ 20 (-96.32%)
Mutual labels:  lambda
aws-maven-plugin
Deploys resources to AWS using maven
Stars: ✭ 25 (-95.4%)
Mutual labels:  lambda
serverless-plugin-parcel
A Serverless framework plugin to bundle assets with Parcel (ES6/7 or Typescript)
Stars: ✭ 23 (-95.76%)
Mutual labels:  lambda
terraform-lambda-fixed-ip
Provide a fixed IP (ElasticIP) to your AWS Lambdas
Stars: ✭ 20 (-96.32%)
Mutual labels:  lambda
cora
Genius programmer should write his own lisp!
Stars: ✭ 40 (-92.63%)
Mutual labels:  lambda
lambda2js
Converts a C# expression tree (from Linq namespace) to a syntatically correct javascript code.
Stars: ✭ 51 (-90.61%)
Mutual labels:  lambda
pulumi-aws-serverless
Easy serverless programming for AWS
Stars: ✭ 15 (-97.24%)
Mutual labels:  lambda
terraform-aws-efs-backup
Terraform module designed to easily backup EFS filesystems to S3 using DataPipeline
Stars: ✭ 40 (-92.63%)
Mutual labels:  lambda
ooso
Java library for running Serverless MapReduce jobs
Stars: ✭ 25 (-95.4%)
Mutual labels:  lambda
go-appsync-graphql-cloudformation
AWS AppSync GraphQL API Proxy with Lambda, CloudFormation, and SAM
Stars: ✭ 28 (-94.84%)
Mutual labels:  lambda
lambda-resize-image
An AWS Lambda Function to resize images automatically with API Gateway and S3 for imagemagick tasks. When an image is called on AWS Api Gateway, this package will resize it and send it to the S3.
Stars: ✭ 56 (-89.69%)
Mutual labels:  lambda
slic-watch
Easy alarms and dashboards for Lambda, DynamoDB, API Gateway, Kinesis, Step Functions and more
Stars: ✭ 88 (-83.79%)
Mutual labels:  lambda

Sidecar for Laravel

Tests Latest Stable Version Total Downloads License

Deploy and execute AWS Lambda functions from your Laravel application.

Read the full docs at hammerstone.dev/sidecar/docs.

Follow me on Twitter for more updates: twitter.com/aarondfrancis

To install, simply require the package from composer: composer require hammerstone/sidecar

This package is still under development, please open issues for anything you run into.

What Sidecar Does

Sidecar packages, creates, deploys, and executes Lambda functions from your Laravel application.

You can write functions in any of the following runtimes and execute them straight from PHP:

  • Node.js 14
  • Node.js 12
  • Node.js 10
  • Python 3.9
  • Python 3.8
  • Python 3.7
  • Python 3.6
  • Python 2.7
  • Ruby 2.7
  • Ruby 2.5
  • Java 11
  • Java 8
  • Go 1.x
  • .NET 6
  • .NET Core 3.1
  • .NET Core 2.1

Any runtime that Lambda supports, you can use!

Hammerstone

Sidecar is maintained by Aaron Francis. If you find it useful consider checking out Refine which allows your users to easily create filters you can run on your app’s data. Works with Laravel and Vue 2 or Vue 3.

What It Looks Like

Every Sidecar Function requires two things:

  • A PHP Class
  • Files that you want deployed to Lambda

For example, if we were wanting to use Node on Lambda to generate an og:image for all of our blog posts, we would first set up a simple class in PHP called OgImage.

App\Sidecar\OgImage.php

namespace App\Sidecar;

use Hammerstone\Sidecar\LambdaFunction;

class OgImage extends LambdaFunction
{
    public function handler()
    {
        // Define your handler function. 
        return 'lambda/image.handler';
    }

    public function package()
    {
        // All files and folders needed for the function.
        return [
            'lambda',
        ];
    }
}

That's it! There are a lot more options, but that's all that is required.

The second thing you'd need is your function's "handler", in this case a javascript file.

Here's a simple JS file that could serve as our handler:

resources/lambda/image.js

const {createCanvas} = require('canvas')

exports.handler = async function (event) {
    const canvas = createCanvas(1200, 630)
    const context = canvas.getContext('2d')

    context.font = 'bold 70pt Helvetica'
    context.textAlign = 'center'
    context.fillStyle = '#3574d4'

    // Read the text out of the event passed in from PHP.
    context.fillText(event.text, 600, 170);
    
    // Return an image.
    return canvas.toDataURL('image/jpeg');
}

With those files created, you can deploy this function to Lambda:

php artisan sidecar:deploy --activate

And then execute it straight from your Laravel app!

web.php

Route::get('/ogimage', function () {
    return OgImage::execute([
        'text' => 'PHP to JS and Back Again!'
    ]);
});

Sidecar passes the payload from execute over to your Javascript function. Your Javascript function generates an image and sends it back to PHP.

Sidecar reduces the complexity of deploying small bits of code to Lambda.

Why Sidecar Exists

AWS Lambda is a powerful service that allows you to run code without provisioning or thinking about servers.

Laravel Vapor brought that power to Laravel. Using Vapor, you can run your plain ol' Laravel apps on a serverless platform and get incredible speed, security, and reliability.

Using Lambda through Vapor is a wonderful developer experience, but there are times when building your applications that you need to run just one or two Node functions for some reason. Common use cases could be taking screenshots with headless Chrome, generating images, or doing server-side rendering of your Javascript frontend.

Or maybe you want to run a Python script without configuring a server? Or a single Ruby script. Or even Java!

When running on a serverless platform, it's not quite as easy as installing Node and running your functions. You don't have access to the server! So you end up deploying a single Vercel or Netlify function and calling it over HTTP or just forgetting the thing altogether.

Sidecar brings the ease of Vapor to those non-PHP functions.

What Sidecar Doesn't Do

Sidecar does not handle any API Gateway, Databases, Caches, etc. The only thing Sidecar concerns itself with is packaging, creating, deploying, and executing Lambda functions.

Sidecar does not provide a way to execute a function via HTTP. You must execute it from your Laravel app through the provided methods.

If you need those other services, you are encouraged to use the instances that Vapor has set up for you, or set them up yourself.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].