From b2d0afc6c2415561a7b4d11c1281f1873748e9fe Mon Sep 17 00:00:00 2001 From: Simone Peniti Date: Thu, 17 Apr 2025 17:21:12 +0200 Subject: [PATCH 1/2] Enable FFI extension --- php-80/Dockerfile | 4 +++- php-81/Dockerfile | 4 +++- php-82/Dockerfile | 4 +++- php-83/Dockerfile | 4 +++- php-84/Dockerfile | 4 +++- tests/test_2_extensions.php | 5 +++-- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/php-80/Dockerfile b/php-80/Dockerfile index 3461e04f..2e0e335d 100644 --- a/php-80/Dockerfile +++ b/php-80/Dockerfile @@ -18,7 +18,8 @@ RUN set -xe \ # Download yum repository data to cache && yum makecache \ # Install default development tools (gcc, make, etc) - && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default + && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default \ + && yum install -y libffi libffi-devel # The default version of cmake is 2.8.12. We need cmake to build a few of @@ -449,6 +450,7 @@ RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I --enable-intl=shared \ --enable-soap \ --with-xsl=${INSTALL_DIR} \ + --with-ffi \ # necessary for `pecl` to work (to install PHP extensions) --with-pear \ # extra compilation flags diff --git a/php-81/Dockerfile b/php-81/Dockerfile index 45231bd3..05774e45 100644 --- a/php-81/Dockerfile +++ b/php-81/Dockerfile @@ -18,7 +18,8 @@ RUN set -xe \ # Download yum repository data to cache && yum makecache \ # Install default development tools (gcc, make, etc) - && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default + && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default \ + && yum install -y libffi libffi-devel # The default version of cmake is 2.8.12. We need cmake to build a few of @@ -470,6 +471,7 @@ RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I --enable-intl=shared \ --enable-soap \ --with-xsl=${INSTALL_DIR} \ + --with-ffi \ # necessary for `pecl` to work (to install PHP extensions) --with-pear \ # extra compilation flags diff --git a/php-82/Dockerfile b/php-82/Dockerfile index 68e47dfc..1547f4e5 100644 --- a/php-82/Dockerfile +++ b/php-82/Dockerfile @@ -18,7 +18,8 @@ RUN set -xe \ # Download yum repository data to cache && yum makecache \ # Install default development tools (gcc, make, etc) - && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default + && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default \ + && yum install -y libffi libffi-devel # The default version of cmake is 2.8.12. We need cmake to build a few of @@ -470,6 +471,7 @@ RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I --enable-intl=shared \ --enable-soap \ --with-xsl=${INSTALL_DIR} \ + --with-ffi \ # necessary for `pecl` to work (to install PHP extensions) --with-pear \ # extra compilation flags diff --git a/php-83/Dockerfile b/php-83/Dockerfile index ef3e673f..a0c882be 100644 --- a/php-83/Dockerfile +++ b/php-83/Dockerfile @@ -18,7 +18,8 @@ RUN set -xe \ # Download yum repository data to cache && yum makecache \ # Install default development tools (gcc, make, etc) - && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default + && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default \ + && yum install -y libffi libffi-devel # The default version of cmake is 2.8.12. We need cmake to build a few of @@ -470,6 +471,7 @@ RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I --enable-intl=shared \ --enable-soap \ --with-xsl=${INSTALL_DIR} \ + --with-ffi \ # necessary for `pecl` to work (to install PHP extensions) --with-pear \ # extra compilation flags diff --git a/php-84/Dockerfile b/php-84/Dockerfile index 3c3404c8..ff2e09c1 100644 --- a/php-84/Dockerfile +++ b/php-84/Dockerfile @@ -18,7 +18,8 @@ RUN set -xe \ # Download yum repository data to cache && yum makecache \ # Install default development tools (gcc, make, etc) - && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default + && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default \ + && yum install -y libffi libffi-devel # The default version of cmake is 2.8.12. We need cmake to build a few of @@ -471,6 +472,7 @@ RUN CFLAGS="-fstack-protector-strong -fpic -fpie -O3 -I${INSTALL_DIR}/include -I --enable-intl=shared \ --enable-soap \ --with-xsl=${INSTALL_DIR} \ + --with-ffi \ # necessary for `pecl` to work (to install PHP extensions) --with-pear \ # extra compilation flags diff --git a/tests/test_2_extensions.php b/tests/test_2_extensions.php index 950bd554..932f55ed 100644 --- a/tests/test_2_extensions.php +++ b/tests/test_2_extensions.php @@ -64,6 +64,7 @@ 'readline' => READLINE_LIB === 'readline', 'reflection' => class_exists(\ReflectionClass::class), 'session' => session_status() === PHP_SESSION_NONE, + 'ffi' => class_exists(\FFI::class), 'zip' => class_exists(\ZipArchive::class), 'zlib' => md5(gzcompress('abcde')) === 'db245560922b42f1935e73e20b30980e', ]; @@ -94,11 +95,11 @@ if ($private_key === false) { return false; } - + $public_key_pem = openssl_pkey_get_details($private_key)['key']; $details = openssl_pkey_get_details(openssl_pkey_get_public($public_key_pem)); return $details['bits'] === 2048; - })(), + })(), 'json' => function_exists('json_encode'), 'bcmath' => function_exists('bcadd'), 'ctype' => function_exists('ctype_digit'), From 2513c9b1410fd21a8e9019ae099bf14336384268 Mon Sep 17 00:00:00 2001 From: Simone Peniti Date: Fri, 18 Apr 2025 16:19:15 +0200 Subject: [PATCH 2/2] Moved libffi-devel installation to the correct place --- php-80/Dockerfile | 7 +++---- php-81/Dockerfile | 6 +++--- php-82/Dockerfile | 6 +++--- php-83/Dockerfile | 6 +++--- php-84/Dockerfile | 6 +++--- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/php-80/Dockerfile b/php-80/Dockerfile index 2e0e335d..88133c44 100644 --- a/php-80/Dockerfile +++ b/php-80/Dockerfile @@ -18,8 +18,7 @@ RUN set -xe \ # Download yum repository data to cache && yum makecache \ # Install default development tools (gcc, make, etc) - && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default \ - && yum install -y libffi libffi-devel + && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default # The default version of cmake is 2.8.12. We need cmake to build a few of @@ -381,8 +380,8 @@ RUN make && make install # libicu-devel : needed for intl # libxslt-devel : needed for the XSL extension # sqlite-devel : Since PHP 7.4 this must be installed (https://github.com/php/php-src/blob/99b8e67615159fc600a615e1e97f2d1cf18f14cb/UPGRADING#L616-L619) -RUN LD_LIBRARY_PATH= yum install -y readline-devel gettext-devel libicu-devel libxslt-devel sqlite-devel - +# libffi-devel : needed for the FFI extension +RUN LD_LIBRARY_PATH= yum install -y readline-devel gettext-devel libicu-devel libxslt-devel sqlite-devel libffi-devel # Note: this variable is used when building extra/custom extensions, do not remove ENV PHP_BUILD_DIR=/tmp/php diff --git a/php-81/Dockerfile b/php-81/Dockerfile index 05774e45..cb9e5628 100644 --- a/php-81/Dockerfile +++ b/php-81/Dockerfile @@ -18,8 +18,7 @@ RUN set -xe \ # Download yum repository data to cache && yum makecache \ # Install default development tools (gcc, make, etc) - && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default \ - && yum install -y libffi libffi-devel + && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default # The default version of cmake is 2.8.12. We need cmake to build a few of @@ -402,7 +401,8 @@ RUN make && make install # gettext-devel : needed for the --with-gettext flag # libicu-devel : needed for intl # libxslt-devel : needed for the XSL extension -RUN LD_LIBRARY_PATH= yum install -y readline-devel gettext-devel libicu-devel libxslt-devel +# libffi-devel : needed for the FFI extension +RUN LD_LIBRARY_PATH= yum install -y readline-devel gettext-devel libicu-devel libxslt-devel libffi-devel # Note: this variable is used when building extra/custom extensions, do not remove diff --git a/php-82/Dockerfile b/php-82/Dockerfile index 1547f4e5..4e72e618 100644 --- a/php-82/Dockerfile +++ b/php-82/Dockerfile @@ -18,8 +18,7 @@ RUN set -xe \ # Download yum repository data to cache && yum makecache \ # Install default development tools (gcc, make, etc) - && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default \ - && yum install -y libffi libffi-devel + && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default # The default version of cmake is 2.8.12. We need cmake to build a few of @@ -402,7 +401,8 @@ RUN make && make install # gettext-devel : needed for the --with-gettext flag # libicu-devel : needed for intl # libxslt-devel : needed for the XSL extension -RUN LD_LIBRARY_PATH= yum install -y readline-devel gettext-devel libicu-devel libxslt-devel +# libffi-devel : needed for the FFI extension +RUN LD_LIBRARY_PATH= yum install -y readline-devel gettext-devel libicu-devel libxslt-devel libffi-devel # Note: this variable is used when building extra/custom extensions, do not remove diff --git a/php-83/Dockerfile b/php-83/Dockerfile index a0c882be..83d465a0 100644 --- a/php-83/Dockerfile +++ b/php-83/Dockerfile @@ -18,8 +18,7 @@ RUN set -xe \ # Download yum repository data to cache && yum makecache \ # Install default development tools (gcc, make, etc) - && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default \ - && yum install -y libffi libffi-devel + && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default # The default version of cmake is 2.8.12. We need cmake to build a few of @@ -402,7 +401,8 @@ RUN make && make install # gettext-devel : needed for the --with-gettext flag # libicu-devel : needed for intl # libxslt-devel : needed for the XSL extension -RUN LD_LIBRARY_PATH= yum install -y readline-devel gettext-devel libicu-devel libxslt-devel +# libffi-devel : needed for the FFI extension +RUN LD_LIBRARY_PATH= yum install -y readline-devel gettext-devel libicu-devel libxslt-devel libffi-devel # Note: this variable is used when building extra/custom extensions, do not remove diff --git a/php-84/Dockerfile b/php-84/Dockerfile index ff2e09c1..480f84b3 100644 --- a/php-84/Dockerfile +++ b/php-84/Dockerfile @@ -18,8 +18,7 @@ RUN set -xe \ # Download yum repository data to cache && yum makecache \ # Install default development tools (gcc, make, etc) - && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default \ - && yum install -y libffi libffi-devel + && yum groupinstall -y "Development Tools" --setopt=group_package_types=mandatory,default # The default version of cmake is 2.8.12. We need cmake to build a few of @@ -405,7 +404,8 @@ RUN make && make install # gettext-devel : needed for the --with-gettext flag # libicu-devel : needed for intl # libxslt-devel : needed for the XSL extension -RUN LD_LIBRARY_PATH= yum install -y readline-devel gettext-devel libicu-devel libxslt-devel +# libffi-devel : needed for the FFI extension +RUN LD_LIBRARY_PATH= yum install -y readline-devel gettext-devel libicu-devel libxslt-devel libffi-devel # Note: this variable is used when building extra/custom extensions, do not remove