This is a suggestion of compilation directive to use when compiling PHP specifically for the audited code.
The selection made below is based on the extension usage, found in the code (--enable, --with) and also the absence of usage (--disable, --without).
Some local extensions (--pdo-mysql, --with-libmbfl...) are also mentionned for help.
# install 15 extra extensions
#pecl install amqp (https://pecl.php.net/package/amqp)
#pecl install ds (https://pecl.php.net/package/ds)
#pecl install php-ffi (https://github.com/dstogov/php-ffi)
#pecl install igbinary (https://pecl.php.net/package/igbinary)
#pecl install libsodium (https://pecl.php.net/package/libsodium)
#pecl install memcached (https://pecl.php.net/package/memcached)
#pecl install mongodb (https://pecl.php.net/package/mongodb)
#pecl install php-psr (https://github.com/jbboehr/php-psr)
#pecl install redis (https://pecl.php.net/package/redis)
#pecl install suhosin.org (https://suhosin.org/)
#pecl install swoole-src (https://github.com/swoole/swoole-src)
#pecl install uopz (https://github.com/krakjoe/uopz)
#pecl install weakref (https://pecl.php.net/package/weakref)
#pecl install xdebug (https://pecl.php.net/package/xdebug)
#pecl install zookeeper (https://pecl.php.net/package/zookeeper)
;;;;;;;;;;;;;;;;;;;;;;;;
; PHP configure list ;
;;;;;;;;;;;;;;;;;;;;;;;;
./configure
--with-amqp
--with-librabbitmq-dir[=DIR]
--with-password-argon2
--with-curl=DIR
--enable-dba=shared
--with-dbm=DIR
--with-ndbm=DIR
--with-db2=DIR
--with-db3=DIR
--with-db4=DIR
--with-cdb=DIR
--with-flatfile
--with-inifile
--with-qdbm=DIR
--with-tcadb=DIR
--enable-ds
--with-ffi[=DIR]
--with-gd
--with-jpeg-dir=DIR
--with-png-dir=DIR
--with-xpm-dir=DIR
--with-vpx-dir=DIR
--with-freetype-dir=DIR
--enable-gd-native-ttf
--with-gmp
--with-igbinary
--enable-intl
--with-ldap[=DIR]
--with-ldap-sasl[=DIR]
--with-libsodium[=DIR]
--enable-mbstring
--with-libmbfl=DIR
--enable-mbstr-enc-trans
--disable-mbregex
--with-libmemcached-dir=DIR
--with-zlib-dir=DIR
--disable-memcached-session
--enable-memcached-sasl
--enable-mongodb
--with-openssl-dir[=DIR]
--with-system-ciphers
--with-mysqli
--enable-opcache
--with-openssl[=DIR]
--enable-pcntl
--enable-pdo
--with-pdo-odbc
--with-pdo-mysql
--with-pdo-pgsql
--with-pdo-oci
--with-pdo-firebird
--with-pdo-dblib
--with-pdo-cubrid
--without-pear
--with-pgsql=[DIR]
--enable-psr
--enable-redis
--disable-redis-session
--enable-redis-igbinary
--enable-sysvsem
--enable-simplexml
--without-sqlite3
--enable-suhosin
--enable-suhosin-experimental
--with-swoole
--enable-swoole-debug, --enable-sockets, --enable-ringbuffer, --enable-async-redis, --enable-openssl, --enable-http2, --enable-thread, --enable-hugepage, --enable-swoole, --enable-mysqlnd, --enable-coroutine, --enable-picohttpparser, --enable-timewheel
--with-uuid=[DIR]
--enable-weakref
--with-xdebug
--with-xmlrpc[=DIR]
--disable-xmlwriter
--with-zlib=DIR
--enable-zookeeper
--disable-zookeeper-session
--with-libzookeeper-dir[=DIR]
; For debug purposes
;--enable-dtrace
;--disable-phpdbg
;--enable-zend-signals
;--disable-opcache