Search code examples
phpcompilationdomdocumentphp-7.4

how to get DOMDocument when compiling PHP7.4 from source?


how do you get DOMDocument when compiling php7.4 from source? i'm on Amazon Linux 2 and compiling php7.4 like this:

yum install autoconf bison re2c libxml2 gcc && \
rm -rf php-src && \
git clone -b 'PHP-7.4' --depth 1 https://github.com/php/php-src.git && \
cd 'php-src' && \
./buildconf && \
./configure --disable-all --disable-cgi --enable-cli --with-curl --with-libxml && \
make clean && \
make -j $(nproc) && \
rm -rfv ../php && \
cp -v ./sapi/cli/php ../php

and to my amazement, the resuling php-cli binary does not have DOMDocument available:

[root@ip-192-168-84-98 php]# ./php test.php 

Fatal error: Uncaught Error: Class 'DOMDocument' not found in /hans_temp/php/test.php:558
Stack trace:
#0 /hans_temp/php/test.php(573): get_gps_coordiates_from_finn_id('237587045')
#1 {main}
  thrown in /hans_temp/php/test.php on line 558

i thought --with-libxml was supposed to add DOMDocument, but here it doesn't... i can theorize that there is a bug between the flags --disable-all and --with-libxml -or- that i'm missing something for DOMDocument support, help? (fwiw the --with-curl works great, adding the curl_* api)

config.log: https://termbin.com/18i8 (too big to inline on stackoverflow.com )


Solution

  • when compiling with --disable-all, you need both --with-libxml and --enable-dom for DOMDocument to be available.

    ./configure --disable-all --enable-cli --with-libxml --enable-dom