Search This Blog

Thursday, December 29, 2005

PHP 4.3 + XSLT + Expat + Sablot + Fedora Core 3

While trying to configure xslt for PHP 4.3, you experience the problem of
Call to undefined function: xslt_create()

You have configured PHP with --enable-xslt --with-xslt-sablot. You google. Everyone tells you to recompile your PHP using the above options and it works. You tear off your hair as you have already used the options but you still get the error. You dont get much help anywhere. You think of leaving out the xslt part or even leaving PHP completly.
Then you find something regarding PHP5. You think of upgrading to PHP5 to avoid such frustrations as PHP5 uses DOM.

If this is your story you are at the right place because i have been through the same. I wasted around 2 days searching for it.
After much search i found 2 pages that helped me get through though not completly.

http://in.php.net/xslt/
(please chk the comments on)
http://www.indexdata.dk/keystone/doc/redhat.tkl

For PHP4 to use xslt you need to install expat and sablot in the given order.

How to install sablotron with PHP
You need to first install expat, followed by Sablotron. Then you need to reinstall PHP. This is the method we used :-

Get source for expat
http://sourceforge.net/projects/expat/ (check for latest)
wget http://telia.dl.sourceforge.net/sourceforge/expat/expat-1.95.8.tar.gz
tar -pxzf expat-1.95.8.tar.gz
cd expat-1.95.8
./configure
make
make install

*Make sure that /etc/ld.so.conf contains /usr/local/lib
then run
ldconfig

Get the source from http://www.gingerall.com
http://download-1.gingerall.cz/download/sablot/Sablot-1.0.2.tar.gz
tar -pxzf Sablot-1.0.2.tar.gz
cd Sablot-1.0.2
export CXXFLAGS=-lstdc++
./configure --prefix=/usr --with-expat --with-iconv
make
make install
ldconfig

Sablot has a seg fault bug. Install its patch.

try reinstalling PHP with --enable-xslt --with-xslt-sablot. If you dont get the Call to undefined function: xslt_create() error, you are lucky.
Else

  1. Check the version of PHP installed. Simplest option would be run page with as you would need the original configure options.
  2. Download the PHP source for same version.
  3. Extract the source. cd to the source dir. Then cd ext/xslt.
  4. vi config.m4 (steps 4 and 5 may not be needed)
  5. comment these 3 lines:
     PHP_SETUP_ICONV(XSLT_SHARED_LIBADD, [], [
    AC_MSG_ERROR([iconv not found, in order to build sablotron you
    need the iconv library])
    ])
  6. now
    phpize
    ./configure --enable-xslt --with-xslt-sablot=/usr/local + (the original configure options)
    make
    su
    make install
  7. xslt.so is created in modules directory in srcdir/ext/xslt/modules copy it to /usr/lib/php4. Change its permissions.
  8. cd /usr/local/lib. Change the permissions for libexpat.a and libsablot.a.

And bingo!
Its done.
For RH8 and RH9 you may need to add extension=xslt.so.