{"id":14446681,"url":"https://github.com/aarondfrancis/sidecar","last_synced_at":"2025-05-14T16:14:03.111Z","repository":{"id":39900807,"uuid":"362656180","full_name":"aarondfrancis/sidecar","owner":"aarondfrancis","description":"Deploy and execute AWS Lambda functions from your Laravel application.","archived":false,"fork":false,"pushed_at":"2024-08-20T16:14:17.000Z","size":496,"stargazers_count":861,"open_issues_count":33,"forks_count":65,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-04-01T23:46:49.359Z","etag":null,"topics":["aws-lambda","lambda","laravel","serverless","sidecar"],"latest_commit_sha":null,"homepage":"https://hammerstone.dev/sidecar/docs/main","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aarondfrancis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-29T01:39:29.000Z","updated_at":"2025-03-26T08:28:41.000Z","dependencies_parsed_at":"2024-03-20T23:43:50.898Z","dependency_job_id":"beca65e2-c7b6-4d23-84b5-bd68c9171737","html_url":"https://github.com/aarondfrancis/sidecar","commit_stats":{"total_commits":199,"total_committers":28,"mean_commits":7.107142857142857,"dds":0.592964824120603,"last_synced_commit":"19bd73bdaceb7dd6a65c9c663e87ce06d62b825d"},"previous_names":["aarondfrancis/sidecar","hammerstonedev/sidecar"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarondfrancis%2Fsidecar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarondfrancis%2Fsidecar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarondfrancis%2Fsidecar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aarondfrancis%2Fsidecar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aarondfrancis","download_url":"https://codeload.github.com/aarondfrancis/sidecar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166925,"owners_count":21058481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","lambda","laravel","serverless","sidecar"],"created_at":"2024-09-01T07:01:00.821Z","updated_at":"2025-05-14T16:14:03.092Z","avatar_url":"https://github.com/aarondfrancis.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Sidecar for Laravel\n\n[![Tests](https://github.com/hammerstonedev/sidecar/actions/workflows/tests.yml/badge.svg)](https://github.com/hammerstonedev/sidecar/actions/workflows/tests.yml) [![Latest Stable Version](https://poser.pugx.org/hammerstone/sidecar/v)](//packagist.org/packages/hammerstone/sidecar) [![Total Downloads](https://poser.pugx.org/hammerstone/sidecar/downloads)](//packagist.org/packages/hammerstone/sidecar) [![License](https://poser.pugx.org/hammerstone/sidecar/license)](//packagist.org/packages/hammerstone/sidecar)\n\n### Deploy and execute AWS Lambda functions from your Laravel application.\n\n\u003e Read the full docs at [hammerstone.dev/sidecar/docs](https://hammerstone.dev/sidecar/docs/main/overview).\n\nFollow me on Twitter for more updates: [twitter.com/aarondfrancis](https://twitter.com/aarondfrancis).\n\nIf you're a visual learner, watch the [Laracasts series](https://laracasts.com/series/developing-serverless-functions-in-laravel).\n\nTo install, simply require the package from composer: `composer require hammerstone/sidecar`\n\nThis package is still under development, please open issues for anything you run into.\n\n## What Sidecar Does\n\nSidecar packages, creates, deploys, and executes Lambda functions from your Laravel application.\n\nYou can write functions in any of the following runtimes and execute them straight from PHP:\n\n- Node.js 20\n- Node.js 18\n- Python 3.12\n- Python 3.11\n- Python 3.10\n- Python 3.9\n- Java 21\n- Java 17\n- Java 11\n- Java 8\n- .NET 8\n- .NET 6\n- Ruby 3.3\n- Ruby 3.2\n- OS-only runtime (Amazon Linux 2023)\n- OS-only runtime (Amazon Linux 2)\n\nAny runtime that [Lambda supports](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html), you can use!\n\nSidecar is maintained by [Aaron Francis](https://twitter.com/aarondfrancis), go follow me on Twitter!\n\n### What It Looks Like\n\nEvery Sidecar Function requires two things:\n\n- A PHP Class\n- Files that you want deployed to Lambda\n\nFor 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`.\n\n`App\\Sidecar\\OgImage.php`\n\n```php\nnamespace App\\Sidecar;\n\nuse Hammerstone\\Sidecar\\LambdaFunction;\n\nclass OgImage extends LambdaFunction\n{\n    public function handler()\n    {\n        // Define your handler function.\n        return 'lambda/image.handler';\n    }\n\n    public function package()\n    {\n        // All files and folders needed for the function.\n        return [\n            'lambda',\n        ];\n    }\n}\n```\n\nThat's it! There are a lot more options, but that's all that is required.\n\nThe second thing you'd need is your function's \"handler\", in this case a javascript file.\n\nHere's a simple JS file that could serve as our handler:\n\n`resources/lambda/image.js`\n\n```js\nconst {createCanvas} = require('canvas')\n\nexports.handler = async function (event) {\n    const canvas = createCanvas(1200, 630)\n    const context = canvas.getContext('2d')\n\n    context.font = 'bold 70pt Helvetica'\n    context.textAlign = 'center'\n    context.fillStyle = '#3574d4'\n\n    // Read the text out of the event passed in from PHP.\n    context.fillText(event.text, 600, 170);\n\n    // Return an image.\n    return canvas.toDataURL('image/jpeg');\n}\n```\n\nWith those files created, you can deploy this function to Lambda:\n\n```\nphp artisan sidecar:deploy --activate\n```\n\nAnd then execute it straight from your Laravel app!\n\n`web.php`\n\n```php\nRoute::get('/ogimage', function () {\n    return OgImage::execute([\n        'text' =\u003e 'PHP to JS and Back Again!'\n    ]);\n});\n```\n\nSidecar passes the payload from `execute` over to your Javascript function. Your Javascript function generates an image and sends it back to PHP.\n\nSidecar reduces the complexity of deploying small bits of code to Lambda.\n\n\n### Why Sidecar Exists\n\n[AWS Lambda](https://aws.amazon.com/lambda/) is a powerful service that allows you to run code without provisioning or thinking about servers.\n\n[Laravel Vapor](https://vapor.laravel.com/) 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.\n\nUsing 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.\n\nOr maybe you want to run a Python script without configuring a server? Or a single Ruby script. Or even Java!\n\nWhen 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.\n\nSidecar brings the ease of Vapor to those non-PHP functions.\n\n## What Sidecar Doesn't Do\n\nSidecar does _not_ handle any API Gateway, Databases, Caches, etc. The _only_ thing Sidecar concerns itself with is packaging, creating, deploying, and executing Lambda functions.\n\nSidecar does not provide a way to execute a function via HTTP. You must execute it from your Laravel app through the provided methods.\n\nIf you need those other services, you are encouraged to use the instances that Vapor has set up for you, or set them up yourself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarondfrancis%2Fsidecar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faarondfrancis%2Fsidecar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarondfrancis%2Fsidecar/lists"}