PHP wrapper for mapserv CGI

Frank Warmerdam warmerdam at POBOX.COM
Mon Aug 20 17:32:58 EDT 2007


Richard Greenwood wrote:
> I have been using the an ASP wrapper around mapserv.exe to hide my map
> file and do some minor pre-processing that I don't want to do with
> JavaScript on the browser. The technique is describe here:
>    http://mapserver.gis.umn.edu/docs/howto/wms_server
> 
> I'd like to do the same thing, but with PHP. The best I've go so far is:
> <?php
>   passthru("/www/cgi-bin/mapserv QUERY_STRING=map=/path/to/mapfile.map");
> ?>
> Which uses the QUERY_STRING option to execute mapserv in a "shell
> mode". It works, but I wonder if there is a better way, and/or if this
> is a bad way to do it.

Rich,

Certainly, if you pass the user's query string through to the commandline
you need to be careful about quoting.  On Linux it should be sufficient
I think to single quote the QUERY_STRING argument to mapserv.  In the
above case, there are no options to pass extents or other values through.
Is this just a highly simplified example or are you really not needing
to pass anything from the original url?

This general approach works fine if you only want to manipulate the
QUERY_STRING.  If you find you want to do more fancy stuff that can't
be expressed by url to mapserv, you might want to consider using MapScript.
For some discussion of this approach skim:

   http://mapserver.gis.umn.edu/docs/howto/wxs_mapscript/#php-example

(and the whole document).

I recently used Python MapScript and this approach to provide a highly
customized GetFeatureInfo implementation for a MapServer WMS that is
otherwise handled normally.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the mapserver-users mailing list