[Xapian-discuss] Another PHP 5 wrapper...

Daniel Ménard Daniel.Menard at Bdsp.tm.fr
Wed Apr 5 11:58:22 BST 2006


Hi all ! , Bonjour à tous !

n.b.
This is my first post to the list : please correct me if there is 
anything I don't do well.
Also, please note that English is not my native language, so forgive me 
(or correct me) for all the mistakes I will certainly make !

<introduction>

I started to play with Xapian some weeks ago. We are looking for a 
search solution to replace our own database fulltext search engine which 
is getting obsolete (I wrote it many years ago...)

I considered many libraries like Lucene, mnoGoSearch, Sphinx, Zebra, 
Mysql and PostgreSql  fulltext indices, and so on and I must say that 
Xapian is the best 'thing' that I found and it is progressively becoming 
one of my best friend ;-)

What I definitely like in Xapian is :
- the ability to do real-time (re)-indexing on added/modified/deleted 
documents. This is something that products like lucene and others are 
missing (it is a frequent request in the lucene lists)
- the multiple bindings which make it usable from many-languages (our 
current target is PHP)
- the simple but very didactic documentation (e.g. intro_ir.html) and 
the comprehensive answers people like Olly Betts, James Aylett and 
others give to all questions posted on the lists
- the very nice OO api wich make it really simple to use
- the versatility of the product which allows its use in a wide field of 
applications

In fact, I don't know enough English words to say 'congratulations' and 
'thank you' to all who contributed to this great piece of software !

</introduction>

For the same reasons than Paul Dixon pointed out :

http://article.gmane.org/gmane.comp.search.xapian.general/2668
http://blog.dixo.net/2006/04/04/xapian-php5-wrapper/

we also started to make a PHP 5 wrapper around the Xapian php api 
generated by swig.

Ideally, swig will one day be able to generate OO bindings for PHP which 
will make our wrapper useless.
If not, perhaps we will start to write a native PHP extension...

Our goals were:
- target : PHP >= 5.1
- PHP api as friendly as the C++/Java ones
- ability to use native PHP interfaces and constructs like iterators, 
countable, arrayAccess, __toString and so on
- complete documentation for this API (phpdoc)
- ability to replace this wrapper by a native php extension with very 
few impact on client's code.

For now, we have an incomplete (it misses some iterators and some 
classes), not fully tested, but functional wrapper.
Naming conventions used are similar to those used in the java api (we 
use $doc->setData() and not $doc->set_data(), for example).

The wrapper is available here :
http://www.bdsp.tm.fr/aed/xapian/phpXapian-0.1.zip

and the documentation is available here :
http://www.bdsp.tm.fr/aed/xapian/documentation/index.html

Please consider this as very 'alpha' software : we are still refactoring 
the api and the doc, we have not yet written unit tests (we use 
simpletest), and we did not do any performance test for now.

Nevertheless, we used it to create and search a 2,7 Gb database, and it 
runs very well.

I don't know how our wrapper compare with Paul's one. Paul's API is very 
similar to the C++ one, and he used a lot the PHP '__call' magic 
function. It's a brillant idea because most of methods get 'magically' 
defined : size of his wrapper is half of our's and it's probably easier 
to add new method. But extensive use of '__call' probably have a cost, 
and it is not easy to have php documentation at the method level.

The fact that two so similar wrappers appear means that there is a real 
need for an OO API in PHP.
But having two PHP wrappers for Xapian would just add confusion and lost 
of time, so we will discard our wrapper if Paul's one become the 
'official' one.

All usefull comments are welcome !

Best regards,

-- 

Daniel Ménard

Banque de Données Santé Publique
Avenue du Professeur Léon Bernard
35043 Rennes Cédex

Tél. (+33) 2.99.02.29.42
Fax (+33) 2.99.02.26.28
E-mail Daniel.Menard at Bdsp.tm.fr
http://www.bdsp.tm.fr




More information about the Xapian-discuss mailing list