bmoffatt / serverless-php

PHP for AWS Lambda via Serverless Framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

serverless-php

serverless language license

PHP for AWS Lambda via Serverless Framework using Symfony components for dependency injection.

Latest version is on master.

AWS Lambda lets you run code without thinking about servers. Right now you can author your AWS Lambda functions in several langauges natively, but not PHP. This project aims to provide a fully featured shim for authoring your AWS Lambda functions in PHP.

More information about how this works and its performance characteristics can be found on my blog post.

Preview

<?php

use Raines\Serverless\Context;
use Raines\Serverless\Handler;

class HelloHandler implements Handler
{
    public function handle(array $event, Context $context)
    {
        return [
            'statusCode' => 200,
            'body' => 'Hello World!',
        ];
    }
}

Features

Event Data Context Logging Exceptions Environment API Gateway
full full part none full full

Usage

Prerequisites

Install this project:

serverless install --url https://github.com/araines/serverless-php

Deploying to AWS

composer install -o --no-dev
serverless deploy

Running locally

serverless invoke local -f hello

Running on AWS

serverless invoke -f hello

Rebuilding PHP Binary

The PHP binary can be built with any flags you require and at any version.

Prerequisites

Compiling

sh buildphp.sh

Altering compile flags etc

Edit buildphp.sh and dockerfile.buildphp to alter it.

Thanks

About

PHP for AWS Lambda via Serverless Framework

License:MIT License


Languages

Language:PHP 68.3%Language:JavaScript 21.2%Language:Shell 10.5%