The Quercus documentation explains how to extend PHP with new functions
by subclassing AbstractQuercusModule and registering the derived class
as an extension provider by adding its name to the service information
file "classes/META-INF/services/com.caucho.quercus.QuercusModule".

I was wondering if it was also possible to extend PHP with new classes
that could be manipulated just as in PHP?

What I had in mind was to map a subset of the functionality provided
by the DOM and Xsl extensions for PHP, which are based on LibXML2 and
LibXSLT, to Quercus. Code like the following could then run in Quercus:

   $doc = new DOMDocument();
   $xsl = new XSLTProcessor();


   echo $xsl->transformToXML($doc);

What would I have to do in order to get there?

(Meanwhile I've seen that an upcoming release of Quercus will include
the DOM module. That still leaves the XSL module to do, which would
allow PHP code to tap into XSLT 2.0 by plugging Saxon into the JAXP
interface. Pretty cool.)

I tried to post this question to the quercus-interest list, but that
wasn't working. Instead, I got an answer off-list by one of the Caucho
engineers, which I'd like to share for everyone to benefit.

The solution is easy, but as far as I can see, it has not been
documented so far. In order to register a new class with Quercus,
simply add the fully qualified class name to the service information
file "classes/META-INF/services/com.caucho.quercus.QuercusClass".

So this is what you have to do:

15:57:19,07 C:\MILU\Server\Tomcat60\webapps\quercus\WEB-INF\classes
# type META-INF\services\com.caucho.quercus.QuercusClass

15:58:03,89 C:\MILU\Server\Tomcat60\webapps\quercus\WEB-INF\classes
# type milu\
package milu;

import com.caucho.quercus.module.AbstractQuercusModule;

public class DOMDocument extends AbstractQuercusModule {
     public String saveXML() {
         return "<Urmel/>";

And then in PHP:

$dom = new DOMDocument();
# load some content, do some work
echo $dom->saveXML();

Michael Ludwig

resin-interest mailing list

Reply via email to