The basics of using Serverless Framework for AWS Lambda PHP applications.
- Install Serverless Framework globally by following the Quick Start
- Install Composer following these instructions
- Install Composer dependencies via
./bin/composer.phar install
- Set up your AWS credentials
- Write your serverless application (!) - the default is in
src/hello.handler.php
- Run
sls deploy
to deploy to Lambda - Run
sls invoke -f hello -l
to invoke your function
The signature for the PHP function is:
function main($event) : array
Hello world looks like:
<?php
function hello($event) : array
{
return ["msg" => "Hello from PHP " . PHP_VERSION];
}