ssigwart / lambda-php
PHP runtime for AWS lambda.
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/ssigwart/lambda-php
Requires
- php: >=7.0.0
- guzzlehttp/guzzle: ^7.2
This package is auto-updated.
Last update: 2025-10-23 10:57:22 UTC
README
cd scripts
./buildRuntime.sh
Writing a Lambda Handler
- Write a class that implements
ssigwart\LambdaRuntime\LambdaHandlerInterface. - Write a
bootstrap.phpfile that calls\LambdaRuntimeBootstrap\RuntimeBootstrap::setHandler()to set your handler.- This file can do additional work, such as setting up autoloading.
- Place your files in a
handler/your_handler_namedirectory, zip, and upload to lambda.- Make sure handler name configured in Lambda matches
your_handler_name.
- Make sure handler name configured in Lambda matches
Sample Handler
<?php use ssigwart\LambdaRuntime\LambdaHandlerInterface; /** Simple lamdba handler */ class MyHandler implements LambdaHandlerInterface { /** * Handle request * * @param string $invocationId Invocation ID * @param string $payload Payload (typically JSON) * * @return string Response */ public function handleRequest(string $invocationId, string $payload): string { return 'Invocation ' . $invocationId . ' with payload: ' . $payload; } } // Set handler \LambdaRuntimeBootstrap\RuntimeBootstrap::setHandler(new MyHandler());
Managing Lambda Layers
Uploading a Layer
- Add
runtime.zipto an S3 bucket - Upload layer to lambda
aws --profile=YOUR_PROFILE lambda publish-layer-version --layer-name YOUR_LAYER_NAME --description "PHP 8.0 runtime." --content S3Bucket=YOUR_BUCKET,S3Key=YOUR_S3_PATH/runtime.zip - Save ARN and use it to add to lambda
Setting Layers on a Lambda Function
aws --profile=YOUR_PROFILE lambda update-function-configuration --function-name YOUR_FUNCTION --layers arn:aws:lambda:us-east-1:635144173025:layer:YOUR_LAYER_NAME:1
Deleteing a Layer
aws --profile=YOUR_PROFILE lambda delete-layer-version --layer-name=YOUR_LAYER_NAME --version-number=1
Listing Layers
aws --profile=YOUR_PROFILE lambda list-layers aws --profile=YOUR_PROFILE lambda list-layer-versions --layer-name=YOUR_LAYER_NAME