DEV Community

Michael Sanford
Michael Sanford

Posted on • Originally published at Medium on

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
Enter fullscreen mode Exit fullscreen mode

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](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
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

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

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

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
Enter fullscreen mode Exit fullscreen mode

Hopefully, you will see the following line:

XSLCACHE =\> enabled
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (0)