Koozali.org: home of the SME Server

PHP with XSLT transformations

Ard

PHP with XSLT transformations
« on: April 14, 2006, 12:40:36 PM »
Please look at the bottom of this tread. To have php-xslt available, there's no need to compile the packages yourself: just install the RPMs (see below).

For our web server we need the XSLT transformations which are not supplied with CentOS. Therefore, I had to make it myself ;-) Here's a short description of what I did.

First you need to add some 3rd party yum repositories. See: http://no.longer.valid/phpwiki/index.php/3rdPartyYumRepositories  
for that.

The compile you also need the devtools for sme7. I have used:
Code: [Select]
wget http://mirror.contribs.org/smeserver/contribs//hmuhammad/install-devtools-7.0.sh
bash ./install-devtools-7.0.sh


You also need to patch the source code of php and the spec file that comes with the src rpm of php:

Create the file php.spec.patch:

Code: [Select]
*** /usr/src/redhat/SPECS/php.spec.orig 2005-11-04 17:32:09.000000000 +0100
--- /usr/src/redhat/SPECS/php.spec      2006-04-13 13:42:32.000000000 +0200
***************
*** 2,7 ****
--- 2,9 ----
  %define with_oci8 %{?_with_oci8:1}%{!?_with_oci8:0}
  %define with_mssql %{?_with_mssql:1}%{!?_with_mssql:0}
  %define with_mhash %{?_with_mhash:1}%{!?_with_mhash:0}
+ # Portions (c) 2005 PD Inc http://www.pdinc.us LICENSE 20050531P00
+ %define xslt 1

  Summary: The PHP HTML-embedded scripting language. (PHP: Hypertext Preprocessor)
  Name: php
***************
*** 63,68 ****
--- 65,73 ----
  Patch81: php-4.3.9-CVE-2005-3388.patch
  Patch82: php-4.3.9-CVE-2005-3353.patch

+ # Skip pspell test
+ Patch90: php-4.3.9-pspell-skip-tests.patch
+
  BuildRoot: %{_tmppath}/%{name}-root

  BuildRequires: bzip2-devel, curl-devel >= 7.9, db4-devel, expat-devel
***************
*** 202,207 ****
--- 207,227 ----
  support for accessing OCI8 databases to PHP.
  %endif

+ %if %{xslt}
+ %package xslt
+ Group: Development/Languages
+ Summary: A module for PHP applications that use Sablotron XSLT.
+ BuildRequires: js, js-devel, sablotron, sablotron-devel
+ Requires: php = %{version}-%{release}
+ # why does this get AutoReq 0?
+ AutoReq: 0
+ Requires: js, sablotron
+
+ %description xslt
+ This PHP extension provides an API to XSLT transformations. Currently this extension only supports the
+ Sablotron library from the Ginger Alliance.
+ %endif
+
  %if %{with_mssql}
  %package mssql
  Group: Development/Languages
***************
*** 332,337 ****
--- 352,359 ----
  %patch81 -p1 -b .cve3388
  %patch82 -p1 -b .cve3353

+ %patch90 -p1 -b .pspelltests
+
  # Prevent %%doc confusion over LICENSE files
  cp Zend/LICENSE Zend/ZEND_LICENSE
  cp TSRM/LICENSE TSRM_LICENSE
***************
*** 433,438 ****
--- 455,465 ----
        --enable-sysvshm \
        --enable-track-vars \
        --enable-trans-sid \
+ %if %{xslt}
+         --enable-xslt=shared \
+         --with-xslt-sablot=shared \
+         --with-sablot-js=shared \
+ %endif
        --enable-yp \
        --enable-wddx \
        --with-pear=/usr/share/pear \
***************
*** 521,526 ****
--- 548,554 ----
  # Generate files lists and stub .ini files for each subpackage
  for mod in pgsql mysql odbc ldap snmp domxml xmlrpc imap \
      mbstring ncurses gd \
+     %{?xslt:xslt} \
      %{?_with_oci8:oci8} %{?_with_mssql:mssql} %{?_with_mhash:mhash}; do
      cat > $RPM_BUILD_ROOT%{_sysconfdir}/php.d/${mod}.ini <<EOF
  ; Enable ${mod} extension module
***************
*** 590,595 ****
--- 618,627 ----
  %files oci8 -f files.oci8
  %endif

+ %if %{xslt}
+ %files xslt -f files.xslt
+ %endif
+
  %if %{with_mssql}
  %files mssql -f files.mssql
  %endif


And the file php-4.3.9-pspell-skip-tests.patch
Code: [Select]
*** php-4.3.9/ext/pspell/tests/01pspell_basic.phpt.org  2006-04-13 13:26:17.000000000 +0200
--- php-4.3.9/ext/pspell/tests/01pspell_basic.phpt      2006-04-13 12:44:52.000000000 +0200
***************
*** 2,8 ****
  pspell basic tests (warning: may fail with pspell/aspell < GNU Aspell 0.50.3)
  --SKIPIF--
  <?php
!       if &#40;!extension_loaded&#40;"pspell"&#41;&#41; print "skip";
        
if &#40;!@pspell_new &#40;"en", "", "", "", &#40;PSPELL_FAST|PSPELL_RUN_TOGETHER&#41;&#41;&#41; &#123;
                
die&#40;"skip English dictionary is not avaliable"&#41;;
        
&#125;
--- 2,----
  
pspell basic tests &#40;warning&#58; may fail with pspell/aspell < GNU Aspell 0.50.3&#41;
  
--SKIPIF--
  <?
php
!       if &#40;1 || !extension_loaded&#40;"pspell"&#41;&#41; print "skip";
        
if &#40;!@pspell_new &#40;"en", "", "", "", &#40;PSPELL_FAST|PSPELL_RUN_TOGETHER&#41;&#41;&#41; &#123;
                
die&#40;"skip English dictionary is not avaliable"&#41;;
        
&#125;



Then execute the following script
Code: [Select]
yum install --enablerepo=\* install expat-devel js-devel ncurses-devel readline-devel
# Download Sablotron source RPM from dags repository.
wget http://dag.wieers.com/packages/sablotron/sablotron-1.0.2-1.rf.src.rpm
# Install the sablotron source RPM and remove "--with-readline" from the spec file.
rpm -ivh sablotron-1.0.2-1.rf.src.rpm
cp /usr/src/redhat/SPECS/sablotron.spec /usr/src/redhat/SPECS/sablotron.spec.org
cat /usr/src/redhat/SPECS/sablotron.spec.org | sed -e 's/--with-readline//' > \
   /usr/src/redhat/SPECS/sablotron.spec
# Build and install sablotron and sablotron-devel packages
rpmbuild -bb /usr/src/redhat/SPECS/sablotron.spec
yum localinstall /usr/src/redhat/RPMS/i386/sablotron-*.rpm
# Download the php source RPM from Redhat.
wget ftp://ftp.redhat.com/pub/redhat/linux/updates/enterprise/4WS/en/os/SRPMS/php-4.3.9-3.9.src.rpm
# Install the php source RPM and add, "--enable-xslt --with-xslt-sablot --with-sablot-js=%{_prefix}" to the spec file.
rpm -ivh php-4.3.9-3.9.src.rpm
# Add a patch to skip the pspell tests produce an compile error on my machine
cp php-4.3.9-pspell-skip-tests.patch /usr/src/redhat/SOURCES
# Patch the spec file with a patch downloaded from: https://bugzilla.redhat.com/bugzilla/attachment.cgi?id=115311
cd /usr/src/redhat/SPECS/
patch -b -p0 < php.spec.patch
# Try to build the php package and force install the of missing packages (mostly -devel packages).
for package in rpmbuild -bb /usr/src/redhat/SPECS/php.spec 2>&1 | awk '{ print $1; }'; do \
   echo $package needs to be installed; yum -y --enablerepo=base install $package; done
# The above succeeds, except for aspell-devel. We need to rebuild this as well
wget http://mirror.contribs.org/smeserver/releases/7/builds/rpms/SRPMS/aspell-0.60.3-2.src.rpm
rpm -ivh aspell-0.60.3-2.src.rpm
rpmbuild -bb /usr/src/redhat/SPECS/aspell.spec
yum localinstall /usr/src/redhat/RPMS/i386/aspell-devel*.rpm
rpmbuild -bb /usr/src/redhat/SPECS/php.spec
# Install the newly build package
yum localinstall /usr/src/redhat/RPMS/i386/php-xslt-4.3.9-3.9.i386.rpm
# The next is not strictly necessary:
rpm -ivh --force /usr/src/redhat/RPMS/i386/php-4.3.9-3.9.i386.rpm


This should do the job. I hope this is useful to the SME community.

Regards, Ard

Offline gregswallow

  • *
  • 651
  • +1/-0
PHP with XSLT transformations
« Reply #1 on: April 14, 2006, 07:12:06 PM »
You could just share the php-xslt rpm you made instead of asking everyone to follow along your howto.  Email staffatcontribs.org if you'd like a ftp directory.

Ard

PHP with XSLT transformations
« Reply #2 on: April 14, 2006, 08:15:53 PM »
I'm not asking everyone to follow this howto.  :-?  On the contrary, I just thought that it would be useful to gather all the information that is scattered around the internet about making the php-xslt extension. So if you make a ftp directory for me, I will upload the .rpm so people do not have to install and compile everything like I did.

Regards, Ard

Ard

PHP with XSLT transformations
« Reply #3 on: April 23, 2006, 09:21:38 PM »
The contribs directory has been created so I've uploaded the required RPM's to http://mirror.contribs.org/smeserver/contribs/ard/

I'll upload a HOWTO soon. For now, just download and install the RPMs. They should work with a plain vanilla SME7rc1 install.

If anything is wrong,  please reply to this thread.

Best regards,

Ard

Ard

PHP with XSLT transformations
« Reply #4 on: May 01, 2006, 10:05:38 AM »
I've just uploaded a freshly compiled php-xslt for SME7.0 RC2. So use
php-xslt-4.3.9-3.9  for SME7.0 RC1 and
php-xslt-4.3.9-3.12 for SME7.0 RC2

Use:
Code: [Select]
yum localinstall sablotron-1.0.2-1.rf.i386.rpm
yum localinstall php-xslt-4.3.9-3.<version>.i386.rpm
service httpd-e-smith restart

and everything should run smoothly.

Offline stiperstones

  • *
  • 177
  • +0/-0
    • http://www.stiperstones.com
missing dependacys
« Reply #5 on: May 02, 2006, 05:58:40 PM »
Ard
yum install gives missing dependacy's this is report from yum any ideas.

yum localinstall php-xslt-4.3.9-3.12.i386.rpm sablotron-1.0.2-1.rf.i386.rpm
==============================================================
WARNING: Additional commands may be required after running yum
==============================================================
Setting up Local Package Process
Examining php-xslt-4.3.9-3.12.i386.rpm: php-xslt - 4.3.9-3.12.i386
Examining sablotron-1.0.2-1.rf.i386.rpm: sablotron - 1.0.2-1.rf.i386
Marking php-xslt-4.3.9-3.12.i386.rpm to be installed
Marking sablotron-1.0.2-1.rf.i386.rpm to be installed
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package sablotron.i386 0:1.0.2-1.rf set to be updated
---> Package php-xslt.i386 0:4.3.9-3.12 set to be updated
--> Running transaction check
Setting up repositories
smeaddons                 100% |=========================|  951 B    00:00
contrib                   100% |=========================|  951 B    00:00
updates                   100% |=========================|  951 B    00:00
smeupdates-testing        100% |=========================|  951 B    00:00
smeos                     100% |=========================|  951 B    00:00
smeupdates                100% |=========================|  951 B    00:00
Reading repository metadata in from local files
--> Processing Dependency: js for package: php-xslt
--> Processing Dependency: libjs.so.1 for package: sablotron
--> Finished Dependency Resolution
Error: Missing Dependency: js is needed by package php-xslt
Error: Missing Dependency: libjs.so.1 is needed by package sablotron

thanks
Alan
Stiperstones

http://wiki.contribs.org/Koozali_Foundation
Try the Wiki some great how's there

"My Licence".........

Don't report security issues here - Contact security at contribs dot org
Don't report problems here - Please report bugs @ http://bugs.contribs.org/
Don't ask the same question twice - Please search the forums, your question may have been asked before - Thank You.

Ard

Re: missing dependacys
« Reply #6 on: May 02, 2006, 06:16:52 PM »
Alan,

The missing dependencies can be found e.g. at the DAG repositories. The easiest is to set up the 3rd party yum repositories  http://no.longer.valid/phpwiki/index.php/3rdPartyYumRepositories  
and then install the pakages with
Code: [Select]
yum --enablerepo=dag localinstall php-xslt-4.3.9-3.12.i386.rpm sablotron-1.0.2-1.rf.i386.rpm


This should do the job (although I haven't tested it .  ;-) ). Alternatively, you can download the js package and install it by hand.

Regards, Ard

Offline stiperstones

  • *
  • 177
  • +0/-0
    • http://www.stiperstones.com
success
« Reply #7 on: May 02, 2006, 09:00:07 PM »
Ard
Yes success after enableing dag repo
=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 php-xslt                i386       4.3.9-3.12       php-xslt-4.3.9-3.12.i386.rpm   28 k
 sablotron               i386       1.0.2-1.rf       sablotron-1.0.2-1.rf.i386.rpm  914 k
Installing for dependencies:
 js                      i386       1.5-1.2.el4.rf   dag               709 k

Transaction Summary
=============================================================================

Thanks agian
Alan
Stiperstones

http://wiki.contribs.org/Koozali_Foundation
Try the Wiki some great how's there

"My Licence".........

Don't report security issues here - Contact security at contribs dot org
Don't report problems here - Please report bugs @ http://bugs.contribs.org/
Don't ask the same question twice - Please search the forums, your question may have been asked before - Thank You.