[MS4W-Users] Missing functions/attributes in MapScript (PHP)

Gramenz, Jens Jens.Gramenz at leibniz-liag.de
Fri Jan 28 10:48:45 UTC 2022


Dear list and especially dear Jeff,
thank you for creating and supporting MS4W. Although MS4W doesn't completely fit our demand, it is marvelous how easy it is to set it up. :)

I wanted to have a look at the new Mapserver/PHP-Combo and tried to make one of our projects work with it. After fixing some deprecations here and there, I encountered some difficulties with MapScript I was not able to circumvent. :(

When switching to PHP7 I had to include the php_mapscript.dll and (I guess that was the SWIG-Version then?!) a mapscript.php.
Sven brought this up in a message in december. This time there is no more mapscript.php and if I include the old one it raises an error, that the classes are already there, which is plausible. But if I don't it seems that there is something (i.e. some functions and attributes [e.g. mapObject->numLayers]) missing. But in general MapScript is loaded and does work.

Since I wasn't sure if it is a problem with my software setup, I used a plain version of MS4W (5beta2) on another machine to reproduce it. Took about 5 Minutes to unzip and about 5 seconds to make it work... Wow!

An example to reproduce my problem is to add the following lines to quickmap.php at line 20 and comment the rest of the file.

$layer = $oMap->getLayer(0);
echo "Layer: ".$layer->name."<br>";
print_r(get_object_vars($layer->metadata));
echo $layer->metadata->wms_title."<br>";
$layer->getMetaData("wms_title");

Getting the layer and printing the name ("ocean") does work. The metadata actually is a hashTableObj, but get_object_vars gives an empty array. Directly accessing the attribute just returns NULL. Calling getMetaData() like we used to leads to the "Fatal error: Uncaught Error: Call to undefined method layerObj::getMetaData()" although is it mentioned in both the SWIG and PHP MapScript API.

Don't know if these a bugs or features. =) Could it be that there have been some changes in the code that are not yet documented? Maybe one of you can bring some light into the darkness?!

Kind regards,
Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ms4w.com/pipermail/ms4w-users/attachments/20220128/7acbfe41/attachment.htm>


More information about the MS4W-Users mailing list