[Xapian-discuss] PHP Bindings

Olly Betts olly at survex.com
Wed Sep 8 02:32:16 BST 2004


I've just spent a couple of hours hacking away at the PHP bindings.  A
quick summary:

* We no longer use the -phpfull option to SWIG (which constructs a mini
  autoconf project and then builds it).  Instead we just build the
  required library using libtool as we do for all the other SWIG
  bindings.  This avoids problems with newer versions of libtool
  and also means that you can now build the PHP4 bindings against
  an uninstalled xapian-core (like you already could for all the other
  languages).

* The documentation and examples are now actually shipped!

* I've fixed some inaccuracies in the documentation.

* simplesearch.php to work with multi term queries.

* simplesearch.php and simpleindex.php now load the xapian PHP extension
  using: dl('xapian.so');

Questions:

Is the last fix actually what we should be doing?  How did you run these
scripts, James?  Using php.ini?

There's a more elaborate version here which takes care of the extension
already being loaded and also works on Windows (though probably not on
some other UNIX platforms - they don't all use .so for shared objects):

http://www.php.net/manual/en/function.dl.php

We should really add a "Xapian_" prefix to everything - as it is we
rather pollute the namespace, and prefixing like this is the norm for
php (e.g.  MySQL is wrapped as mysql_*).  Anyone know how to do this
with SWIG?  For Tcl, swig has a -prefix option, but not for php4.

Also, why do we rename empty methods to is_empty?  PHP4 has a built in
function called empty, but since we prefix methods with the class name,
MSet::empty() would become MSet_empty() anyway.

We also rename empty to is_empty for the Python bindings, but again
for no reason I can see: Python's Queue class has an empty() method, so
it seems unlikely we can't...

And a bonus question: why does the C++ API have Query::is_empty()?
I think for consistency we should probably add Query::empty() and
deprecate Query::is_empty()...

Cheers,
    Olly



More information about the Xapian-discuss mailing list