You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-8
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
1
# PHP Layer For AWS Lambda
2
2
3
-
Ever wanted to run PHP websites in AWS Lambda? It's your lucky day! This Lambda Runtime Layer runs the [PHP 7.1 webserver](http://php.net/manual/en/features.commandline.webserver.php) in response to [AWS API Gateway](https://aws.amazon.com/api-gateway/) or [AWS Application Load Balancer](https://aws.amazon.com/elasticloadbalancing/features/#Details_for_Elastic_Load_Balancing_Products) requests.
3
+
Ever wanted to run PHP websites in AWS Lambda? It's your lucky day! This Lambda Runtime Layer runs the [PHP 7.1/7.2/7.3 webserver](http://php.net/manual/en/features.commandline.webserver.php) in response to [AWS API Gateway](https://aws.amazon.com/api-gateway/) or [AWS Application Load Balancer](https://aws.amazon.com/elasticloadbalancing/features/#Details_for_Elastic_Load_Balancing_Products) requests.
4
4
5
5
And, if you're looking for a great way to build serverless apps of all kinds, be sure to check out [Stackery](https://stackery.io)!
6
6
7
7
This is an early iteration of the PHP runtime Layer which is not yet ready for production. Please feel free to use this Layer to learn about the Lambda Layers feature and begin experimenting with PHP functions. We welcome feedback and stay tuned for the production-ready version coming soon.
8
8
9
9
## Current Layer Version ARN
10
-
When creating/updating a Lambda function you must specify a specific version of the layer. This readme will be kept up to date with the latest version available. The latest available Lambda Layer Version ARN is:
10
+
When creating/updating a Lambda function you must specify a specific version of the layer. This readme will be kept up to date with the latest version available. The latest available Lambda Layer Version ARN for PHP 7.1 is:
See [Releases](https://github.com/stackery/php-lambda-layer/releases) for release notes.
15
15
16
16
### Usage
17
17
#### General Usage
18
-
The layer runs the PHP 7.1[PHP webserver](http://php.net/manual/en/features.commandline.webserver.php) in /var/task, the root directory of function code packages:
18
+
The layer runs the PHP 7.*[PHP webserver](http://php.net/manual/en/features.commandline.webserver.php) in /var/task, the root directory of function code packages:
19
19
20
20
```sh
21
21
$ php -S localhost:8000 '<handler>'
@@ -26,12 +26,14 @@ The Lambda Function Handler property specifies the location of the the script ex
26
26
#### Configuration Files
27
27
There are three locations where PHP configuration may be located:
28
28
29
-
* Files in layer code packages located under /etc/php-7.1.d/
30
-
* Files in function code package located under /php-7.1.d/
29
+
* Files in layer code packages located under /etc/php-${PHP_VERSION}.d/
30
+
* Files in function code package located under /php-${PHP_VERSION}.d/
31
31
* php.ini located at the root of the function code package
32
32
33
+
Replace ${PHP_VERSION} with '7.1', '7.2', or '7.3' according to your preferred runtime.
34
+
33
35
##### Extensions
34
-
The following extensions are built into the layer and available in /opt/lib/php/7.1/modules:
36
+
The following extensions are built into the layer and available in /opt/lib/php/${PHP_VERSION}/modules:
35
37
36
38
```
37
39
bz2.so
@@ -68,7 +70,7 @@ These extensions are not loaded by default. You must add the extension to a php.
68
70
extension=json.so
69
71
```
70
72
71
-
Extensions can be built using the lambci/lambda:build-nodejs8.10 Docker image. It is recommended that custom extensions be provided by a separate Lambda Layer with the extension .so files placed in /lib/php/7.1/modules/ so they can be loaded alongside the built-in extensions listed above.
73
+
Extensions can be built using the lambci/lambda:build-nodejs8.10 Docker image. It is recommended that custom extensions be provided by a separate Lambda Layer with the extension .so files placed in /lib/php/${PHP_VERSION}/modules/ so they can be loaded alongside the built-in extensions listed above.
72
74
73
75
#### SAM Example
74
76
Let's create an AWS SAM PHP application. We suggest using [Stackery](https://stackery.io) to make this super simple. It automates all the scaffolding shown below. But you may also choose to roll your own application from scratch.
@@ -149,6 +151,32 @@ Build the layer by:
149
151
150
152
This will launch a Docker container that will build php71.zip.
151
153
154
+
You can run `make php72.zip` and `make php73.zip` to create a layer that is based on PHP 7.2/7.3.
155
+
156
+
If you are behind a proxy server, just set the environment variable `http_proxy` before
157
+
invoking `make`, eg.:
158
+
159
+
```sh
160
+
$ export http_proyx=http://myproxy.acme.com:8080
161
+
$ make php73.zip
162
+
```
163
+
164
+
### Debugging
165
+
166
+
Run:
167
+
168
+
```sh
169
+
$ docker run --rm -it -v `pwd`:/opt/layer lambci/lambda:build-nodejs8.10 /bin/bash
170
+
```
171
+
172
+
If you are on Windows, run this instead:
173
+
174
+
```sh
175
+
> docker run --rm -it -v %cd%:/opt/layer lambci/lambda:build-nodejs8.10 /bin/bash
176
+
```
177
+
178
+
and execute manually the commands in the build.sh file.
179
+
152
180
### Disclaimer
153
181
154
182
> THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
@@ -162,4 +190,4 @@ This will launch a Docker container that will build php71.zip.
162
190
> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
163
191
> STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
164
192
> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
0 commit comments