[Xapian-discuss] PHP bindings
Francis Irving
francis@flourish.org
Wed, 26 May 2004 11:17:40 +0100
--2B/JsCI69OhZNC5r
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Wed, May 26, 2004 at 10:16:13AM +0100, James Aylett wrote:
> I'm good with PHP4, but I haven't yet managed to get the bindings to
> build. If someone wants to send me a .so of the Xapian PHP4 bindings
> either for 32bit i386-linux or for 32bit sparc-solaris, I'll have a
> look at doing that (based on the Python ones).
I've sent you a xapian.so by private email.
For others who are interested find two attached files which might help
with Xapian and PHP. INSTALL-xap has our internal project
instructions on how we got the bindings working. testxap.php is
an example of the Xapian syntax in PHP.
Francis
--2B/JsCI69OhZNC5r
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=INSTALL-xap
Install Xapian
--------------
% wget http://www.tartarus.org/~olly/xapian-0.8/xapian-core-0.8.0.tar.gz
unpack,
% cd xapian-core-0.8.0
% ./configure
% make
% su
# make install
Perl bindings:
# perl -MCPAN -e shell
.
.
.
cpan> install Search::Xapian
.
.
.
cpan> quit
Lockfile removed.
SWIG:
# pkg_fetch swig
# pkg_add /path/to/swig
PHP bindings:
% wget http://www.tartarus.org/~olly/xapian-0.8/xapian-bindings-0.8.0.tar.gz
unpack,
% cd xapian-bindings-0.8.0
Edit php4/util.i:
--- util.i~ 2004-04-30 10:05:53.000000000 +0000
+++ util.i 2004-04-30 10:05:53.000000000 +0000
@@ -22,6 +22,9 @@
* USA
* -----END-LICENCE-----
*/
+
+#define COMPILE_DL_XAPIAN 1
+
%}
%pragma(php4) phpinfo="
% ./configure --without-python (python fucked up for some reason)
% make
I had to manually softlink libtoolize13 to libtoolize in
/usr/local/bin to make this work.
Then I manually installed it:
# cp ~ben/software/unpacked/xapian-bindings-0.8.0/php4/xapian/modules/xapian.so /usr/local/lib/php/
add two lines to /usr/local/etc/php.ini:
extension_dir = "/usr/local/lib/php"
extension = xapian.so
RESTART APACHE!!!
--2B/JsCI69OhZNC5r
Content-Type: application/x-httpd-php
Content-Disposition: attachment; filename="testxap.php"
Content-Transfer-Encoding: quoted-printable
<?=0Aecho "<h1>Xapian testing</h1>";=0A=0A#dl("xapian.so");=0A$db =3D new_d=
atabase();=0Adatabase_add_database($db, open("/home/francis/pwdata/fawkesxa=
piandb"));=0A=0A#$stemmer =3D new_stem('english');=0A#$stemword =3D stem_st=
em_word($stemmer, "house");=0A#print "house stems to " . $stemword;=0A=0A$e=
nquire =3D new_enquire($db);=0A=0A$queryparser =3D new_queryparser();=0A$qu=
ery =3D queryparser_parse_query($queryparser, 'house');=0A=0Aenquire_set_qu=
ery($enquire, $query);=0A=0A$matches =3D enquire_get_mset($enquire, 0, 1000=
0);=0Aprint "<br>size " . mset_size($matches);=0Aprint "<br>estimate " . ms=
et_get_matches_estimated($matches);=0A=0A$iter =3D mset_begin($matches);=0A=
$end =3D mset_end($matches);=0Awhile (!msetiterator_equals($iter, $end))=0A=
{=0A print "<br>item % " . msetiterator_get_percent($iter);=0A print "<br>i=
tem doc " . document_get_data(msetiterator_get_document($iter));=0A mset=
iterator_next($iter);=0A}=0A#mset_fetch($matches, 1, $iter);=0A=0A#foreach =
( $matches as $match)=0A#{=0A# print $match;=0A#}=0A=0A# Who needs document=
ation?=0Aprint "<p>";=0A$fns =3D get_defined_functions();=0Aforeach ( $fns[=
"internal"] as $fn)=0A{=0A print "<br>" . $fn;=0A}=0A=0A=0A?>=0A=0A
--2B/JsCI69OhZNC5r--