Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

Rawencode #58

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
all: php71.zip php73.zip

php71.zip:
docker run --rm -e http_proxy=${http_proxy} -v $(ROOT_DIR):/opt/layer lambci/lambda:build-nodejs8.10 /opt/layer/build.sh
docker run --rm -e http_proxy=${http_proxy} -v $(ROOT_DIR):/opt/layer lambci/lambda:build-provided /opt/layer/build.sh

php73.zip:
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
docker run --rm -e http_proxy=${http_proxy} -v $(ROOT_DIR):/opt/layer lambci/lambda:build-provided /opt/layer/build-php-remi.sh 3

upload71: php71.zip
./upload.sh 7.1
Expand Down
45 changes: 42 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ This is an early iteration of the PHP runtime Layer which is not yet ready for p
## Current Layer Version ARN
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 ARNs for PHP 7.3 and 7.1 are:

**arn:aws:lambda:\<region\>:887080169480:layer:php73:2**
**arn:aws:lambda:\<region\>:887080169480:layer:php73:3**

**arn:aws:lambda:\<region\>:887080169480:layer:php71:9**
**arn:aws:lambda:\<region\>:887080169480:layer:php71:10**

See [Releases](https://github.com/stackery/php-lambda-layer/releases) for release notes.

Expand All @@ -37,6 +37,45 @@ Replace ${PHP_VERSION} with '7.3', or '7.1' according to your preferred runtime.
##### Extensions
The following extensions are built into the layer and available in /opt/lib/php/${PHP_VERSION}/modules:

PHP 7.3 Layer:
```
bz2.so
calendar.so
ctype.so
curl.so
dom.so
exif.so
fileinfo.so
ftp.so
gettext.so
iconv.so
json.so
mbstring.so
mysqli.so
mysqlnd.so
pdo_mysql.so
pdo_pgsql.so
pdo.so
pdo_sqlite.so
pgsql.so
phar.so
posix.so
shmop.so
simplexml.so
sockets.so
sqlite3.so
sysvmsg.so
sysvsem.so
sysvshm.so
tokenizer.so
wddx.so
xmlreader.so
xml.so
xmlwriter.so
xsl.so
```

PHP 7.1 Layer:
```
bz2.so
calendar.so
Expand Down Expand Up @@ -105,7 +144,7 @@ Resources:
Timeout: 30
Tracing: Active
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:887080169480:layer:php73:2
- !Sub arn:aws:lambda:${AWS::Region}:887080169480:layer:php73:3
Events:
api:
Type: Api
Expand Down
14 changes: 4 additions & 10 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,18 @@ while (true) {
$uri .= "&";
}

$uri .= $name;
$uri .= rawurlencode($name) . '=';

if ($value != '') {
$uri .= '=' . $value;
$uri .= rawurlencode($value);
}
}
}
}

$ch = curl_init("http://localhost:8000$uri");

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);

if (array_key_exists('multiValueHeaders', $event)) {
$headers = array();
Expand All @@ -171,13 +171,7 @@ while (true) {
}

if (strlen($body) > 0) {
if($event['httpMethod'] === 'POST'){
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($body));
curl_setopt($ch, CURLOPT_READFUNCTION, function ($ch, $fd, $length) use ($body) {
return $body;
});
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}

$response = array();
Expand Down
8 changes: 4 additions & 4 deletions build-php-remi.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -e

PHP_MINOR_VERSION=$1

Expand All @@ -8,17 +8,16 @@ yum install -y wget
yum install -y yum-utils
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm
rpm -Uvh epel-release-latest-6.noarch.rpm

rpm -Uvh remi-release-6.rpm

yum-config-manager --enable remi-php7${PHP_MINOR_VERSION}

yum install -y httpd
yum install -y postgresql-devel
yum install -y libargon2-devel

yum install -y --disablerepo="*" --enablerepo="remi,remi-php7${PHP_MINOR_VERSION}" php php-mbstring php-pdo php-mysql php-pgsql
yum install -y --disablerepo="*" --enablerepo="remi,remi-php7${PHP_MINOR_VERSION}" php php-mbstring php-pdo php-mysql php-pgsql php-xml php-process


mkdir /tmp/layer
Expand All @@ -37,6 +36,7 @@ done
cp /usr/lib64/libedit.so.0 lib/
cp /usr/lib64/libargon2.so.0 lib/
cp /usr/lib64/libpq.so.5 lib/
cp /usr/lib64/libonig.so.5 lib/

mkdir -p lib/php/7.${PHP_MINOR_VERSION}
cp -a /usr/lib64/php/modules lib/php/7.${PHP_MINOR_VERSION}/
Expand Down