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 14 extra extensions
#pecl install ibm_db2.git (http://git.php.net/?p=pecl/database/ibm_db2.git)
#pecl install igbinary (https://pecl.php.net/package/igbinary)
#pecl install imagick (https://pecl.php.net/package/imagick)
#pecl install libsodium (https://pecl.php.net/package/libsodium)
#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 sqlite (https://pecl.php.net/package/sqlite)
#pecl install sqlsrv (https://pecl.php.net/package/sqlsrv)
#pecl install swoole-src (https://github.com/swoole/swoole-src)
#pecl install tidy (https://pecl.php.net/package/tidy)
#pecl install uopz (https://github.com/krakjoe/uopz)
#pecl install xhprof (https://pecl.php.net/package/xhprof)
;;;;;;;;;;;;;;;;;;;;;;;;
; PHP configure list ;
;;;;;;;;;;;;;;;;;;;;;;;;
./configure
--with-apxs2
--enable-bcmath
--with-curl=DIR
--with-IBM_DB2=[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
--with-imagick=DIR
--with-imap=DIR
--with-imap-ssl=DIR
--with-kerberos=DIR
--enable-intl
--with-interbase[=DIR]
--with-ldap[=DIR]
--with-ldap-sasl[=DIR]
--with-libsodium[=DIR]
--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-mssql=[DIR]
--enable-msdblib
--with-mysqli
--with-oci8
--with-unixodbc[=DIR]
--with-adabas[=DIR]
--with-sapdb[=DIR]
--with-solid[=DIR]
--with-ibm-db2[=DIR]
--with-empress[=DIR]
--with-empress-bcs[=DIR]
--with-birdstep[=DIR]
--with-custom-odbc[=DIR]
--with-iodbc[=DIR]
--with-esoob[=DIR]
--with-openlink[=DIR]
--with-dbmaker[=DIR]
--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
--with-pgsql=[DIR]
--enable-psr
--enable-redis
--disable-redis-session
--enable-redis-igbinary
--enable-simplexml
--enable-sockets
--enable-soap
--with-sqlite=shared
--with-sqlsrv=DIR
--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-uuid=[DIR]
--with-xhprof=DIR
--with-xmlrpc[=DIR]
--with-xsl[=DIR]
--enable-zip
--with-libzip=DIR
--with-zlib=DIR
; For debug purposes
;--enable-dtrace
;--disable-phpdbg
;--enable-zend-signals
;--disable-opcache