Skip to content

Commit 557cbe4

Browse files
Files for PHP 7.2 and 7.3 have been merged together
1 parent 7b6ea9a commit 557cbe4

12 files changed

+50
-655
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ php71.zip:
44
docker run --rm -v $(ROOT_DIR):/opt/layer lambci/lambda:build-nodejs8.10 /opt/layer/build.sh
55

66
php72.zip:
7-
docker run --rm -v $(ROOT_DIR):/opt/layer lambci/lambda:build-nodejs8.10 /opt/layer/build-php72.sh
7+
docker run --rm -e http_proxy=${http_proxy} -v $(ROOT_DIR):/opt/layer lambci/lambda:build-nodejs8.10 /opt/layer/build-php-remi.sh 2
88

99
php73.zip:
10-
docker run --rm -v $(ROOT_DIR):/opt/layer lambci/lambda:build-nodejs8.10 /opt/layer/build-php73.sh
10+
docker run --rm -e http_proxy=${http_proxy} -v $(ROOT_DIR):/opt/layer lambci/lambda:build-nodejs8.10 /opt/layer/build-php-remi.sh 3
1111

1212
upload: php71.zip
1313
./upload.sh

README.md

+34-26
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# PHP Layer For AWS Lambda
22

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.
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.
44

5-
This project is fork of the [Stackery](https://stackery.io) [php-lambda-layer](https://github.com/stackery/php-lambda-layer) that has been modified to:
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)!
66

7-
- support PHP 7.1, 7.2, and 7.3 (the original supports 7.1 only) - using the [Remi RPM Repository](https://rpms.remirepo.net/)
8-
- add support for mbstring, MySQL (pdo-mysql) and Postgres (pdo-pgsql)
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.
98

10-
that are requirements for running frameworks such as [Lumen](https://lumen.laravel.com/) and [Laravel](https://laravel.com/) frameworks in serverless mode.
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 for PHP 7.1 is:
1111

12-
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.
12+
**arn:aws:lambda:\<region\>:887080169480:layer:php71:7**
13+
14+
If you need a layer for PHP 7.2 or 7.3, you can build your own.
15+
You can find an example [here](http://tinyurl.com/ycsbfpbr).
16+
17+
See [Releases](https://github.com/stackery/php-lambda-layer/releases) for release notes.
1318

1419
### Usage
1520
#### General Usage
@@ -24,14 +29,14 @@ The Lambda Function Handler property specifies the location of the the script ex
2429
#### Configuration Files
2530
There are three locations where PHP configuration may be located:
2631

27-
* Files in layer code packages located under /etc/php-<PHP_VERSION>.d/
28-
* Files in function code package located under /php-<PHP_VERSION>.d/
32+
* Files in layer code packages located under /etc/php-${PHP_VERSION}.d/
33+
* Files in function code package located under /php-${PHP_VERSION}.d/
2934
* php.ini located at the root of the function code package
3035

31-
Replace <PHP_VERSION> with 7.1, 7.2, or 7.3 according to your preferred runtime.
36+
Replace ${PHP_VERSION} with '7.1', '7.2', or '7.3' according to your preferred runtime.
3237

3338
##### Extensions
34-
The following extensions are built into the layer and available in /opt/lib/php/7.1/modules (PHP 7.1) or /opt/lib/php/modules (PHP 7.2/7.3):
39+
The following extensions are built into the layer and available in /opt/lib/php/${PHP_VERSION}/modules:
3540

3641
```
3742
bz2.so
@@ -45,20 +50,11 @@ ftp.so
4550
gettext.so
4651
iconv.so
4752
json.so
48-
mbstring.so
49-
mysqli.so
50-
mysqlnd.so
51-
pdo.so
52-
pdo_mysql.so
53-
pdo_pgsql.so
54-
pdo_sqlite.so
55-
pgsql.so
5653
phar.so
5754
posix.so
5855
shmop.so
5956
simplexml.so
6057
sockets.so
61-
sqlite3.so
6258
sysvmsg.so
6359
sysvsem.so
6460
sysvshm.so
@@ -77,7 +73,7 @@ These extensions are not loaded by default. You must add the extension to a php.
7773
extension=json.so
7874
```
7975

80-
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.
76+
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.
8177

8278
#### SAM Example
8379
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.
@@ -110,7 +106,7 @@ Resources:
110106
Timeout: 30
111107
Tracing: Active
112108
Layers:
113-
- !Sub arn:aws:lambda:${AWS::Region}:887080169480:layer:php71:6
109+
- !Sub arn:aws:lambda:${AWS::Region}:887080169480:layer:php71:7
114110
Events:
115111
api:
116112
Type: Api
@@ -154,22 +150,34 @@ $ sam deploy \
154150
Build the layer by:
155151

156152
1. Installing a Docker environment
157-
2. Running `make`
153+
1. Running `make`
158154

159-
This will launch a Docker container that will build php71.zip, based on PHP 7.1 (default).
155+
This will launch a Docker container that will build php71.zip.
160156

161157
You can run `make php72.zip` and `make php73.zip` to create a layer that is based on PHP 7.2/7.3.
162158

159+
If you are behind a proxy server, just set the environment variable `http_proxy` before
160+
invoking `make`, eg.:
161+
162+
```sh
163+
$ export http_proyx=http://myproxy.acme.com:8080
164+
$ make php73.zip
165+
```
166+
163167
### Debugging
164168

165169
Run:
166170

171+
```sh
167172
$ docker run --rm -it -v `pwd`:/opt/layer lambci/lambda:build-nodejs8.10 /bin/bash
168-
173+
```
174+
169175
If you are on Windows, run this instead:
170176

177+
```sh
171178
> docker run --rm -it -v %cd%:/opt/layer lambci/lambda:build-nodejs8.10 /bin/bash
172-
179+
```
180+
173181
and execute manually the commands in the build.sh file.
174182

175183
### Disclaimer
@@ -185,4 +193,4 @@ and execute manually the commands in the build.sh file.
185193
> HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
186194
> STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
187195
> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
188-
> OF THE POSSIBILITY OF SUCH DAMAGE.
196+
> OF THE POSSIBILITY OF SUCH DAMAGE.

bootstrap

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ function start_webserver() {
1818
// exec the command
1919
$HANDLER = getenv('_HANDLER');
2020
chdir('/var/task');
21-
exec("PHP_INI_SCAN_DIR=/opt/etc/php-7.1.d/:/var/task/php-7.1.d/ php -S localhost:8000 -c /var/task/php.ini -d extension_dir=/opt/lib/php/7.1/modules '$HANDLER'");
21+
$phpMinorVersion = PHP_MINOR_VERSION;
22+
exec("PHP_INI_SCAN_DIR=/opt/etc/php-7.${phpMinorVersion}.d/:/var/task/php-7.${phpMinorVersion}.d/ php -S localhost:8000 -c /var/task/php.ini -d extension_dir=/opt/lib/php/7.${phpMinorVersion}/modules '$HANDLER'");
2223
exit;
2324

2425
// return the child pid to parent

bootstrap-php72

-235
This file was deleted.

0 commit comments

Comments
 (0)