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 13 extra extensions
#pecl install amqp (https://pecl.php.net/package/amqp)
#pecl install php-ast (https://github.com/nikic/php-ast)
#pecl install geoip (https://pecl.php.net/package/geoip)
#pecl install imagick (https://pecl.php.net/package/imagick)
#pecl install mailparse (https://pecl.php.net/package/mailparse)
#pecl install memcached (https://pecl.php.net/package/memcached)
#pecl install memcached (https://pecl.php.net/package/memcached)
#pecl install php-psr (https://github.com/jbboehr/php-psr)
#pecl install redis (https://pecl.php.net/package/redis)
#pecl install ssh2 (https://pecl.php.net/package/ssh2)
#pecl install swoole-src (https://github.com/swoole/swoole-src)
#pecl install tidy (https://pecl.php.net/package/tidy)
#pecl install xdebug (https://pecl.php.net/package/xdebug)
;;;;;;;;;;;;;;;;;;;;;;;;
; PHP configure list ;
;;;;;;;;;;;;;;;;;;;;;;;;
./configure
--with-amqp
--with-librabbitmq-dir[=DIR]
--with-apxs2
--enable-ast
--enable-bcmath
--with-bz2=DIR
--enable-calendar
--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-fpm
--with-fpm-user
--with-fpm-group
--with-fpm-systemd
--with-fpm-acl
--enable-ftp
--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-geoip=DIR
--with-gettext=DIR
--with-gmp
--with-imagick=DIR
--with-imap=DIR
--with-imap-ssl=DIR
--with-kerberos=DIR
--enable-intl
--with-ldap[=DIR]
--with-ldap-sasl[=DIR]
--enable-mailparse
--enable-mbstring
--with-libmbfl=DIR
--enable-mbstr-enc-trans
--disable-mbregex
--with-mcrypt=[DIR]
--enable-memcache
--disable-memcache-session
--with-libmemcached-dir=DIR
--with-zlib-dir=DIR
--disable-memcached-session
--enable-memcached-sasl
--with-mysqli
--enable-opcache
--with-openssl[=DIR]
--enable-pdo
--with-pdo-odbc
--with-pdo-mysql
--with-pdo-pgsql
--with-pdo-oci
--with-pdo-firebird
--with-pdo-dblib
--with-pdo-cubrid
--with-pgsql=[DIR]
--enable-psr
--enable-redis
--disable-redis-session
--enable-redis-igbinary
--enable-shmop
--enable-simplexml
--enable-sockets
--enable-soap
--with-ssh2
--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
--enable-tidy=[DIR]
--with-xdebug
--with-xmlrpc[=DIR]
--enable-zip
--with-libzip=DIR
--with-zlib=DIR
; For debug purposes
;--enable-dtrace
;--disable-phpdbg
;--enable-zend-signals
;--disable-opcache