[gdal-dev] Re: PHP bindings

Mike Leahy mgleahy at alumni.uwaterloo.ca
Tue Mar 1 19:11:09 EST 2011


Even/all,

As you recommended, I've created a ticket for this 
(http://trac.osgeo.org/gdal/ticket/3984).  I was able to resolve the function 
name conflicts (I think) that were blocking the gdal/ogr modules.  After this, 
I find that I can get some partial functionality out of the php_ogr.so 
module...though some functions will also produce segfaults.  However, 
php_gdal.so causes PHP to segfault immediately on startup if the module is 
loaded.   I've posted some debug info in the ticket...I think it's something 
to do with null pointers, which I'm guessing may need to be accounted for in 
some way through the php typemaps.

Regards,
Mike

> Date: Tue, 1 Mar 2011 19:59:48 +0100
> From: Even Rouault <even.rouault at mines-paris.org>
> Subject: Re: [gdal-dev] Re: PHP bindings
> To: gdal-dev at lists.osgeo.org, mgleahy at alumni.uwaterloo.ca
> Message-ID: <201103011959.48700.even.rouault at mines-paris.org>
> Content-Type: Text/Plain;  charset="utf-8"
> 
> Mike,
> 
> > Hello again,
> > 
> > I think I stumbled upon the part that was tripping up the methods I was
> > using with the php_osr.so library.  Posted at
> > http://pastebin.com/SXKKfe6v is a patch that should work on both 1.8.0,
> > and the trunk svn.  It adds the missing CSL typemap, and corrects the
> > OGRErr related typemaps to ensure that it only returns results for
> > non-zero error responses.
> 
> I'm not sure if/when someone will act on this, but you should perhaps open
> a GDAL Trac ticket and attach your patch there so it is kept in a safer
> place than a pastebin that will be lost in a few days/weeks.
> 
> > The patch also includes changes to the GNUmakefile in the swig/php folder
> > to make sure that the gdal libs are linked, and that all of the php
> > modules are compiles instead of just php_gdal.so (not sure if this is
> > fully necessary, but I was having trouble with linking before).
> > 
> > In addition to this, I had to substitute all instances of
> > 'zend_error_noreturn' that swig inserts into the *_wrap.cpp files with
> > 'zend_error'...I don't know if this is just specific to my environment,
> > but the best I could determine from searching online is that more recent
> > versions of PHP no longer define zend_error_noreturn, yet swig still
> > uses it.  It seems that zend_error is a sufficient substitute (without
> > this, I would find that when the module raised errors, it would cause a
> > segfault instead of actually producing a descriptive error in
> > Apache/PHP).
> 
> Perhaps something to share with the swig mailing list ?
> 
> > If this patch is applied and gdal is configured/compiled with the
> > '--with-php' option, then when swig/php/php_osr.so is installed and
> > loaded into the PHP environment, the following PHP script will work as
> > expected:
> > 
> > <?php
> > include("/path/to/gdal/swig/php/osr.php");
> > $sr = new SpatialReference();
> > $sr->ImportFromProj4('+init=epsg:4326');
> > echo $sr->ExportToProj4();
> > ?>
> > 
> > This is about as far as I can get for now - looking through
> > typemaps_php.i, I think I see plenty of stuff that still needs
> > fixing/updating.  There are also function name conflicts if I try to
> > load php_gdal.so and/or php_ogr.so.  I think that's out of my league,
> > however.  Hopefully this is enough to peak the interest of someone who
> > has a little more familarity with c/swig/php, and we could get a more
> > fully-supported set of PHP bindings.
> > 
> > Best regards,
> > Mike
> > 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110301/aad884ad/attachment-0001.html


More information about the gdal-dev mailing list