https://github.com/thbley/php-lambda
Getting started with PHP on AWS Lambda
https://github.com/thbley/php-lambda
Last synced: about 1 year ago
JSON representation
Getting started with PHP on AWS Lambda
- Host: GitHub
- URL: https://github.com/thbley/php-lambda
- Owner: thbley
- License: mit
- Created: 2019-02-05T16:20:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-30T21:50:07.000Z (almost 5 years ago)
- Last Synced: 2025-02-16T08:44:43.556Z (over 1 year ago)
- Language: PHP
- Homepage: https://www.youtube.com/watch?v=5cLZ5jT2Gi0
- Size: 2.75 MB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Getting started with PHP on AWS Lambda
```
docker build -t lambda-php-runtime .
docker run --rm --entrypoint /opt/bin/php lambda-php-runtime -v
docker run --rm --entrypoint /opt/bin/php lambda-php-runtime -m
docker run --rm --entrypoint /opt/bin/php lambda-php-runtime -r 'echo 0.7+0.1;'
docker run --rm --entrypoint /opt/bin/php lambda-php-runtime -r 'echo json_encode(0.7+0.1);'
docker run --rm --entrypoint bash lambda-php-runtime -c "cat /opt/bin/php" >bin/php
docker run --rm -v "$PWD":/var/task lambda-php-runtime hello '{"Hello": "bephpug"}'
zip -r runtime.zip bootstrap bin
zip -r vendor.zip vendor/
aws iam create-role \
--role-name LambdaPhp --path "/service-role/" \
--assume-role-policy-document file://trust-policy.json
aws lambda publish-layer-version \
--layer-name php-runtime --region eu-central-1 \
--zip-file fileb://runtime.zip
aws lambda publish-layer-version \
--layer-name php-vendor --region eu-central-1 \
--zip-file fileb://vendor.zip
zip hello.zip src/hello.php
aws lambda create-function --function-name php-hello --handler hello \
--runtime provided --region eu-central-1 \
--zip-file fileb://hello.zip \
--role "arn:aws:iam::" \
--layers "arn:aws:lambda:" \
"arn:aws:lambda: