Compiling xslcache 0.7.1 for PHP 5.4

We make heavy use of xslt at work (parsing xml data generated by php controllers), so the xslcache pecl module is pretty fundamental to our infrastructure. Of course, if you are using PHP 5.4 or above, like many pecl modules, it breaks. Here’s how to get it to work.

Currently, trying sudo pecl install xslcache-beta with PHP >= 5.4 throws the following error at make:

/tmp/pear/temp/xslcache/php_xsl.c: In function 'xslcache_objects_new': /tmp/pear/temp/xslcache/php_xsl.c:211:52: error: 'zend_class_entry' has no member named 'default_properties' make: *** [php_xsl.lo] Error 1 ERROR: `make' failed

Download xslcache

Download the original source from the pecl svn repository, the 5.4 patch, and patch it manually:

svn checkout http://svn.php.net/repository/pecl/xslcache/trunk xslcache cd xslcache wget -O php_xsl.c.patch 'https://bugs.php.net/patch-display.php?bug_id=62856&patch=xslcache-php5.4-compat&revision=1362641549&download=1' patch < php_xsl.c.patch

Make and install

This is a pretty straightforward make process for most linux software (you may need to adjust the location of xslcache.ini):

phpize ./configure make make test sudo make install sudo nano /etc/php5/cgi/conf.d/xslcache.ini #add "extension=xslcache.so"

Note that if you make test the tenth may fail with the following:

=================================================================== FAILED TEST SUMMARY 
------------------------------------------------------------------- Test 10: EXSLT Support [tests/xslt010.phpt] ===================================================================

If you’re using XSLT 2.0, you probably don’t need to worry about it.

Verify that xslcache is installed and enabled

Since we’re already in the command line, let’s check there:

php -i | grep XSLCACHE

Hopefully, you will see the following line:

XSLCACHE => enabled

Furthermore, you should be able to actually know it’s doing its job because your benchmarks should improve.


Originally published at michaelsanford.com on March 22, 2013.

Show your support

Clapping shows how much you appreciated Michael Sanford’s story.