Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
Using img2lambda to publish your Serverless PHP layer
Feb 25, 2019 @ 17:45:24

Rob Allen has published another post covering the use of serverless technology and PHP to run your applications. In this new post he shows how to use img2lambda to publish your Serverless PHP layer out to an AWS Lambda instance.

[The] img2lambda tool will take the layers of a Docker container and convert them to AWS layers for use in Lambda.

I poked around with Clare’s example and updated my lambda-php project in order to understand how it works. I also rewrote my runtime’s bootstrap to make it clearer.

The clever thing from my point of view is that you can build your PHP runtime layer locally using Docker and then publish the layers to AWS for use in your Lambda functions. This means you can now use the layer in different projects and have them all reference the same PHP runtime.

He digs deeper into the tool, looking at the "magic" happening under the covers using Docker. He provides an example of the Dockerfile it creates and walks through what it does. He then shows how to create the layer in AWS and use a serverless framework and a PHP runtime to execute the "hello world" application. He wraps up the post showing how to test it locally, building from the Dockerfile and using a docker run on the result with simple user input.

tagged: tutorial img2lambda docker package serverless layer aws

Link: https://akrabat.com/using-img2lambda-to-publish-your-serverless-php-layer/


Trending Topics: