Skip to main content.
home | support | download

Back to List Archive

RE: Anyone using the PHP module?

From: Bill Moseley <moseley(at)>
Date: Fri Oct 10 2003 - 19:34:04 GMT
On Fri, Oct 10, 2003 at 11:51:46AM -0700, Patrick O'Lone wrote:
> Jose,
> Functionally, I have crossed a bug. But I can't say I like the API that much
> - it functions more like a Perl module rather than a PHP module. Normally,
> PHP modules are engineered just a thin wrapper around the C equivalent
> functions. The official SWISH-E PHP extension returns objects that have
> methods written in C. It's a little different to program with that a
> standard PHP extension would be.
> Normally in PHP, you would do something like:
> <?php
> $hSwishe = swishe_create("index1", "index2");
> ?>
> Where swishe_create() would return a resource rather than an object. I guess
> the design decision was to make it as close the Perl API as possible though,
> huh?

The Perl API is a thin wrapper around the C API, but takes advantage of
Perl's objects -- namely in automatically freeing memory when Perl
variables go out of scope.  I'm sure when I was working on the C API I
was thinking about that.  It really reduces the chance of memory leaks.

I don't know a think about PHP.  What's a "resource" vs. and object in

I just took at look at swishe.c at

Is that programmed to the current 2.4.0 API?

I see these:

void _php_swishe_search_close(zend_rsrc_list_entry *rsrc)
php_swishe_search *search = (php_swishe_search *)rsrc->ptr;


/* destroy a resource of type "swishe_results" */
static void _php_swishe_results_close(zend_rsrc_list_entry *rsrc)
php_swishe_results *results = (php_swishe_results *)rsrc->ptr;


/* destroy a resource of type "swishe_result" */
static void _php_swishe_result_close(zend_rsrc_list_entry *rsrc)
php_swishe_result *result = (php_swishe_result *)rsrc->ptr;


How are they called when using the PHP interface?

I wouldn't use efree() externally, and instead use the API.  
For example, to free a search object (search_close above) I it
should use

  Free_Search_Object( search );

calling efree() directly would cause a memory leak.  For example, inside the search
structure is the query string, sort parameters and -L limit parameters.

> Is there going to be a SWISH-E API for indexing as well?

Considering that indexing is a single command operation, I don't really
see where an API would help.  That's what "system()" is for.

Bill Moseley
Received on Fri Oct 10 19:38:16 2003