Search code examples
phpxmlwriter

Recompiling PHP with xmlreader, xmlwriter enabled


I've noticed that the PHP make that I'm using on a dev box doesn't have the xmlreader and xmlwriter extensions enabled. I understand that I need to recompile PHP to enable those extensions (or maybe more accurately remove the disabling, since they are enabled by default?), but I'm having an issue making the connection in my head from where I need to run the ./configure and make commands.

Here's my Configure Command from a phpinfo() output:

'./configure' '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' \
 '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' \
 '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' \
 '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' \
 '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' \
 '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' \
 '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' \
 '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' \
 '--disable-rpath' '--without-pear' '--with-bz2' '--with-exec-dir=/usr/bin' \
 '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' \
 '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' \
 '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pcre-regex=/usr' \
 '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' \
 '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' \
 '--enable-sysvmsg' '--with-kerberos' '--enable-ucd-snmp-hack' '--enable-shmop' \
 '--enable-calendar' '--without-mime-magic' '--without-sqlite' \
 '--with-libxml-dir=/usr' '--enable-xml' '--with-system-tzdata' \
 '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--disable-dom' \
 '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' \
 '--disable-xmlwriter' '--without-sqlite3' '--disable-phar' '--disable-fileinfo' \
 '--disable-json' '--without-pspell' '--disable-wddx' '--without-curl' \
 '--disable-posix' '--disable-sysvmsg' '--disable-sysvshm' '--disable-sysvsem' 

Notice that it was compiled with --disable-xmlreader and --disable-xmlwriter. According to the documentation at http://www.php.net/manual/en/xmlwriter.installation.php , I see that this extension is enabled by default. How would I "undo" this extension disabling?

My goal is to be able to use the PHPExcel class set ( http://phpexcel.codeplex.com/ ) but am getting a fatal error because one of the classes is attempting to extend the XMLWriter class.


Solution

  • If you are using one of the distros that have binary packages (like openSUSE) - you mihgt want to just install php-xmlwriter package as an extension.

    Another option - just get the source of your version, and compile xmlwriter as a module, using phpize (let me know if more help is needed on this).

    If that does not work - you will need to get a source, and compile everything from scratch. In that case, configure is ran from the folder you extract the source to.

    Additional thing to keep in mind - any extensions that you have installed right now - you will either need to compile them in, or rebuild using the source that you get (unless php version matches - then you can use already installed ones).

    And lastly, distros usually come with a few binaries of php (like CGI, apache module, cli). You will need to make sure you have this (or whatever part you need) enabled in your configure commands as well.