Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sidecar Laravel Package

hammerstone/sidecar

Sidecar lets Laravel package, deploy, and invoke AWS Lambda functions directly from your app. Define a simple PHP class plus the files to ship, choose any supported runtime (Node, Python, Java, .NET, Ruby, or OS-only), and execute from PHP.

View on GitHub
Deep Wiki
Context7

Function Hooks

There are a few ways to interact with your functions during the deployment and activation process.

Sidecar dispatches global events as it's deploying and activating functions, and it also calls instance methods on each function.

The following four methods are available to you on every Sidecar function:

  • beforeDeployment
  • afterDeployment
  • beforeActivation
  • afterActivation

Example: Before Deployment

The beforeDeployment hook is a great place to run a build step if your function requires it. We'll be using the ncc build command mentioned in the Handlers & Packages section for this example.

In this example, we'll use Symfony's Process component to run the ncc command, so that we never forget to build our bundle before we deploy.

use Symfony\Component\Process\Process;

class ExampleFunction extends LambdaFunction
{
    public function beforeDeployment()
    {
        Sidecar::log('Compiling bundle with NCC.');

        $command = ['ncc', 'build', 'resources/lambda/image.js', '-o', 'resources/lambda/dist'];

        Sidecar::log('Running `' . implode(' ', $command). '`');

        $process = new Process($command, $cwd = base_path(), $env = []);

        $process->setTimeout(60)->disableOutput()->mustRun();

        Sidecar::log('Bundle compiled!');
    }
}

With this in place, you'll see something like this in your logs:

[Sidecar] Deploying App\Sidecar\Example to Lambda as `SC-App-local-Sidecar-Example`.
          ↳ Environment: local
          ↳ Runtime: nodejs20.x
          ↳ Compiling bundle with NCC.  [tl! focus]
          ↳ Running `ncc build resources/lambda/image.js -o resources/lambda/dist`  [tl! focus]
          ↳ Bundle compiled!  [tl! focus]
          ↳ Function already exists, potentially updating code and configuration.
          ↳ Packaging files for deployment.
          ↳ Creating a new zip file.
          ↳ Zip file created at s3://sidecar-us-east-2-XXXX/sidecar/001-7a2e86d9853b10c97b970af51d101f8d.zip
          ↳ Function code and configuration updated.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport