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
+5-19Lines changed: 5 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
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/) requests.
4
4
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
+
5
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.
6
8
7
9
## Current Layer Version ARN
@@ -17,7 +19,7 @@ The layer runs the PHP 7.1 [PHP webserver](http://php.net/manual/en/features.com
17
19
$ php -S localhost:8000 '<handler>'
18
20
```
19
21
20
-
The Lambda Function Handler property specifies the location of the of the webserver router script. This script must be provided.
22
+
The Lambda Function Handler property specifies the location of the the script executed in response to an incoming API Gateway request.
21
23
22
24
##### Extensions
23
25
Extensions can be built using the lambci/lambda:build-nodejs8.10 Docker image. It is recommended that extensions be built into a Lambda Layer in /lib/php/7.1/modules. Then, in a php.ini file in the Lambda Function root directory put:
@@ -84,7 +86,7 @@ Resources:
84
86
Description: PHP Webserver
85
87
CodeUri: src/server
86
88
Runtime: provided
87
-
Handler: router.php
89
+
Handler: index.php
88
90
MemorySize: 3008
89
91
Timeout: 30
90
92
Tracing: Active
@@ -98,21 +100,6 @@ Resources:
98
100
Method: ANY
99
101
```
100
102
101
-
Now create the PHP application in `src/server`. We're going to create a webserver router script first. Put the following in `router.php`:
102
-
103
-
```php
104
-
<?php
105
-
if (is_file($_SERVER['DOCUMENT_ROOT'].'/'.$_SERVER['SCRIPT_NAME'])) {
106
-
// Serve static files directly
107
-
return false;
108
-
}
109
-
110
-
// Run index.php for all requests
111
-
$_SERVER['SCRIPT_NAME'] = '/index.php';
112
-
require 'index.php';
113
-
?>
114
-
```
115
-
116
103
Lastly, let's write our script. Put this in `index.php`:
117
104
118
105
```php
@@ -127,8 +114,7 @@ You should now have a directory structure like:
127
114
├── template.yaml
128
115
└── src
129
116
└── php
130
-
├── index.php
131
-
└── router.php
117
+
└── index.php
132
118
```
133
119
134
120
We're ready to deploy! Run the following commands:
0 commit comments