Open roborourke opened 2 years ago
@joehoyle or @rmccue, was there anything special about the process to build the PHP binary? Presumably needs to built using the lambda build container, if you have existing docs or a script that would help.
Hmm I don't remember specifically if we saved that process somewhere. I think I might have followed something like https://aws.amazon.com/blogs/apn/aws-lambda-custom-runtime-for-php-a-practical-example/
FYI I was able to compile specific versions of PHP for lambda, using this Dockerfile. You can copy the PHP bin out of /opt/php-bin/bin/php
:
#Lambda base image Amazon linux
FROM public.ecr.aws/lambda/provided as builder
# Set desired PHP Version
ARG php_version="7.3.6"
RUN echo ${php_version}
RUN yum clean all && \
yum install -y autoconf \
bison \
bzip2-devel \
gcc \
gcc-c++ \
git \
gzip \
libcurl-devel \
libxml2-devel \
make \
openssl-devel \
tar \
unzip \
zip
# Download the PHP source, compile, and install both PHP and Composer
RUN curl -sL https://github.com/php/php-src/archive/php-${php_version}.tar.gz | tar -xvz && \
cd php-src-php-${php_version} && \
./buildconf --force && \
./configure --prefix=/opt/php-bin/ --with-openssl --with-curl --with-zlib --without-pear --enable-bcmath --with-bz2 --enable-mbstring --with-mysqli && \
make -j 5 && \
make install && \
/opt/php-bin/bin/php -v
When the lambda is built we copy the pre-built binary of PHP from an S3 bucket and install it to
/bin/php
.The current version is PHP 7.1 and needs to be updated to a minimum of PHP 7.4 in order to not flag false negatives for PHP syntax errors.
Specifically we are seeing this error:
For code like the following:
Acceptance criteria:
php@7.1
php@7.4
php@8.1
php@7.4
by defaultSuggested config for PHP version: