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 3 extra extensions
#pecl install gnupg (https://pecl.php.net/package/gnupg)
#pecl install imagick (https://pecl.php.net/package/imagick)
#pecl install tidy (https://pecl.php.net/package/tidy)
;;;;;;;;;;;;;;;;;;;;;;;;
; PHP configure list ;
;;;;;;;;;;;;;;;;;;;;;;;;
./configure
--disable-ctype
--with-curl=DIR
--disable-filter
--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-gnupg=DIR
--disable-hash
--with-imagick=DIR
--with-imap=DIR
--with-imap-ssl=DIR
--with-kerberos=DIR
--enable-intl
--disable-libxml
--enable-mbstring
--with-libmbfl=DIR
--enable-mbstr-enc-trans
--disable-mbregex
--with-mysqli
--disable-pdo
--without-pear
--with-pgsql=[DIR]
--disable-posix
--enable-simplexml
--enable-soap
--without-sqlite3
--enable-tidy=[DIR]
--disable-tokenizer
--disable-xmlreader
--with-xmlrpc[=DIR]
--disable-xmlwriter
--enable-zip
--with-libzip=DIR
; For debug purposes
;--enable-dtrace
;--disable-phpdbg
;--enable-zend-signals
;--disable-opcache