[Xapian-discuss] PHP bindings
olly at survex.com
Mon Oct 2 12:32:12 BST 2006
I'm just sorting out the PHP bindings ready for the next release.
Unless I hit a show-stopper, this will include PHP5 bindings which
wrap the Xapian API as PHP5 objects.
Currently the PHP4 bindings use a SWIG option which flattens the
object interface into a series of functions, so you have to write:
$database = new_Database("mydb");
echo Database_get_doccount($database) . " documents\n";
instead of the more natural:
$database = new Database("mydb");
echo $database->get_doccount() . " documents\n";
While object creation is OK, I find actually using objects is much
clumsier under the flat function approach.
The reason we do this is because SWIG's support for the later style was
broken. This has now been fixed, so I'm wondering if we should switch
to using this. The upside is that the PHP4 Xapian API is more natural.
The downside is that existing code will need adapting.
The PHP5 OO interface is actually implemented as a PHP class wrapper
around the flat function interface, so existing code will continue to
work under PHP5 (and with care you can mix and match the two styles).
But that's not the case for PHP4. Modifying SWIG to support this is
possible, but I don't really have the time to do it.
So if you use the Xapian bindings under PHP4 (not PHP5!), do you think
the pain of updating your code is worth the gain from the more OO-like
API? If there was a simple script which did most of the work of
updating your scripts, would that change your opinion?
More information about the Xapian-discuss