Awesome Open Source
Awesome Open Source

PHP with the Serverless Framework

In order to use PHP on AWS Lambda you need to bundle the PHP binary, including the required libraries, into the package. This serverless example project includes the necessary binary to run a simple PHP script.

See my blog post here.


Install this serverless project. It will create a new serverless-php folder.

serverless install --url

Deploying the sample function to AWS

Check the serverless.yml file and modify region and stage if necessary.

sls deploy

Running the function locally

sls invoke local --function hello

Running the function on AWS

sls invoke --function hello

Rebuilding the PHP binary

If you need different compiler flags or dependencies you will need to recompile PHP.


Compile the static standalone PHP 7 binary

To do this, we have to compile the PHP 7.2.2 with statically linked libraries:


PHP Version

The default is to use the PHP 7.2.2 branch to compile the PHP binary. To switch the PHP version you can set the branch PHP_VERSION_GIT_BRANCH parameter in line 8.


Thanks to:

Alternatives To Serverless Php
Select To Compare

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,072,605
Php (287,456
Amazon Web Services (38,412
Lambda Functions (13,970
Serverless (9,908
Compile (9,055
Aws Lambda (3,427
Serverless Framework (1,271