The Foreign Function Interface (or FFI), allow PHP to call C functions and using C data types directly from the language. It’s seems that you don’t have to write a PHP extension in C, you can do it directly in your PHP code. PHP FFI is available as a core extension and it’s not enabled by default.
If you want to try this new feature, you can do it very simply with phpdaily Docker images. You just have to extend the default PHP image, and install the extension.
# Dockerfile
FROM phpdaily/php:7.4.0-dev
RUN apk add --no-cache --virtual .persistent-deps libffi-dev \
&& docker-php-ext-configure ffi --with-ffi \
&& docker-php-ext-install ffi
Then build your Docker image using docker build -t php/ffi
.
Your PHP Docker image with FFI is now ready.