
Aws Lambda Php Integration
Apply PHP-on-Lambda sizing, Composer slimming, structured logging, and safe HTTP responses when shipping Bref or Symfony on AWS.
Overview
aws-lambda-php-integration is an agent skill most often used in Build (backend, also Ship perf, Operate infra) that codifies PHP Lambda memory, package, logging, and error-response best practices.
Install
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill aws-lambda-php-integrationWhat is this skill?
- Memory baselines: 512MB for Symfony, 256MB for raw PHP; timeouts 10–30s (Symfony) vs 3–10s (raw PHP)
- Minimal composer.json pattern with Bref ^2.0, PHP ^8.2, optimize-autoloader and dist installs
- Structured error_log JSON including AWS request_id from Lambda context
- HTTP mapping for 200/400 validation vs 500 with logged exceptions
- Documents Lambda limits: 250MB unzipped package, 128MB–10GB memory range
- 512MB starting memory for Symfony; 256MB for raw PHP
- 250MB maximum unzipped deployment package (50MB zipped)
- Lambda memory range 128MB to 10GB per skill limits section
Adoption & trust: 960 installs on skills.sh; 271 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your PHP Lambda cold-starts, times out, or returns opaque 500s because memory, Composer bloat, and error handling were guessed instead of sized to Lambda limits.
Who is it for?
Indie devs shipping Symfony or raw PHP APIs on Bref who want checklist-level guardrails before production traffic.
Skip if: Teams on long-running PHP-FPM VMs, non-PHP runtimes, or greenfield projects that have not committed to AWS Lambda yet.
When should I use this skill?
Implementing or reviewing PHP handlers on AWS Lambda with Bref/Symfony sizing, dependencies, logging, or HTTP error contracts.
What do I get? / Deliverables
Handlers follow documented memory/timeouts, slim dependencies, structured logs, and consistent JSON error bodies suitable for API Gateway fronts.
- Lambda-compatible handler error responses
- Structured log lines
- Tuned memory/timeout recommendations
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Serverless PHP handlers are authored during build but constraints bite hardest at deploy and in production—primary shelf is backend implementation guidance. Backend subphase is where Lambda handlers, Composer deps, and error/response contracts are defined before CI ships artifacts.
Where it fits
Scaffold a Bref handler with 256MB and a 10s timeout before adding Symfony bundles.
Raise Symfony Lambda memory to 512MB and extend timeout to absorb cold-start latency before launch.
Standardize error_log JSON with request_id when tracing intermittent 500s in CloudWatch.
How it compares
Reference constraints for PHP Lambda—not a full Terraform/CDK deploy skill or generic PHPUnit testing pack.
Common Questions / FAQ
Who is aws-lambda-php-integration for?
Solo and small-team builders deploying PHP 8.2+ on AWS Lambda with Bref and optionally Symfony, using agents for implementation reviews.
When should I use aws-lambda-php-integration?
During Build while writing handlers, during Ship when tuning timeout/memory for cold starts, and during Operate when standardizing JSON logs and 4xx/5xx responses.
Is aws-lambda-php-integration safe to install?
It is documentation-only with no bundled shell or network calls—still review the Security Audits panel on this page before trusting any developer-kit repo fork.
SKILL.md
READMESKILL.md - Aws Lambda Php Integration
# AWS Lambda PHP Best Practices Best practices, constraints, and security considerations for PHP Lambda development. ## Memory and Timeout Configuration - **Memory**: Start with 512MB for Symfony, 256MB for raw PHP - **Timeout**: Set based on expected processing time - Symfony: 10-30 seconds for cold start buffer - Raw PHP: 3-10 seconds typically sufficient ## Dependencies Keep `composer.json` minimal: ```json { "require": { "php": "^8.2", "bref/bref": "^2.0", "symfony/framework-bundle": "^6.0" }, "config": { "optimize-autoloader": true, "preferred-install": "dist" } } ``` ## Error Handling Return proper Lambda responses: ```php try { $result = processRequest($event); return [ 'statusCode' => 200, 'body' => json_encode($result) ]; } catch (ValidationException $e) { return [ 'statusCode' => 400, 'body' => json_encode(['error' => $e->getMessage()]) ]; } catch (Exception $e) { error_log($e->getMessage()); return [ 'statusCode' => 500, 'body' => json_encode(['error' => 'Internal error']) ]; } ``` ## Logging Use structured logging: ```php error_log(json_encode([ 'level' => 'info', 'message' => 'Request processed', 'request_id' => $context->getAwsRequestId(), 'path' => $event['path'] ?? '/' ])); ``` ## Lambda Limits - **Deployment package**: 250MB unzipped maximum (50MB zipped) - **Memory**: 128MB to 10GB - **Timeout**: 29 seconds (API Gateway), 15 minutes for async - **Concurrent executions**: 1000 default ## PHP-Specific Considerations - **Cold start**: PHP has moderate cold start; use Bref for optimized runtimes - **Dependencies**: Keep composer.json minimal; use Lambda Layers for shared deps - **PHP version**: Use PHP 8.2+ for best Lambda performance - **No local storage**: Lambda containers are ephemeral; use S3/DynamoDB for persistence ## Common Pitfalls 1. **Large vendor folder** - Exclude dev dependencies; use --no-dev 2. **Session storage** - Don't use local file storage; use DynamoDB 3. **Long-running processes** - Not suitable for Lambda; use ECS instead 4. **Websockets** - Use API Gateway WebSockets or AppSync instead ## Security Considerations - Never hardcode credentials; use IAM roles and SSM Parameter Store - Validate all input data - Use least privilege IAM policies - Enable CloudTrail for audit logging - Set proper CORS headers # Bref Lambda Reference Complete guide for deploying PHP applications on AWS Lambda using the Bref framework. ## Table of Contents 1. [Project Setup](#project-setup) 2. [Handler Implementation](#handler-implementation) 3. [Symfony Integration](#symfony-integration) 4. [Cold Start Optimization](#cold-start-optimization) 5. [Configuration](#configuration) 6. [Deployment](#deployment) --- ## Project Setup ### Composer Configuration ```json { "name": "my/symfony-lambda", "description": "Symfony on AWS Lambda", "require": { "php": "^8.2", "bref/bref": "^2.0", "bref/symfony-bridge": "^1.0", "symfony/framework-bundle": "^6.0", "symfony/yaml": "^6.0", "symfony/dotenv": "^6.0" }, "require-dev": { "phpunit/phpunit": "^10.0" }, "autoload": { "psr-4": { "App\\": "src/" } }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "allow-plugins": { "php-http/discovery": true } } } ``` ### Serverless Configuration ```yaml # serverless.yml service: symfony-lambda provider: name: aws runtime: php-82 memorySize: 512 timeout: 20 region: us-east-1 plugins: - ./vendor/bref/bref functions: api: handler: public/index.php description: Symfony Lambda events: - httpApi: '*' package: exclude: - node_modules/** - .git/** - tests/** ``` --- ## Handler Implementation ### Basic Lambda Handler ```php // pub