[MS4W-Users] ms4w 4.0.0 PHP-Mapscript Test
Jeff McKenna
jmckenna at gatewaygeomatics.com
Thu Feb 14 10:57:19 EST 2019
Hi Ludwig,
As the instructions that I pasted here in my previous message stated,
PHPmapscript in MS4W verson 4 and onward requires the SWIG MapScript
API. This means that the mapscript function & method names may have
changed, if you have old code that leverages the PHP MapScript API
instead. Therefore the SWIG MapScript API Reference document is now
your guide to follow for all of your function & method names
(https://mapserver.org/mapscript/mapscript.html#swig-mapscript-api-reference).
For example:
- the old PHPmapscript API function ms_ResetErrorList() is now named
msResetErrorList() (according to
https://mapserver.org/mapscript/mapscript.html#mapscript-functions )
- the old PHPmapscript API constructor way for declaring new objects,
such as ms_newLayerObj(), has changed to the syntax: new xxxObj (as you
can see in the layerObj methods at
https://mapserver.org/mapscript/mapscript.html#layerobj-methods )
Here is a working example:
// create new layer object
$oLayer = new layerObj($oMap);
$oLayer->set("name", "cities");
$oLayer->set("type", MS_LAYER_RASTER);
$oLayer->set("status", MS_ON);
$oLayer->setConnectionType(MS_WMS, NULL);
$oLayer->set("CONNECTION",
"https://demo.gatewaygeomatics.com/cgi-bin/wms_gateway?");
$oLayer->setMetaData("wms_name", "popplace");
$oLayer->setMetaData("wms_srs", "EPSG:3978");
$oLayer->setMetaData("wms_server_version", "1.1.1");
$oLayer->setMetaData("wms_format", "image/png");
$oLayer->SetProjection("init=EPSG:3978");
*note that there is a missing alias for the set() method, as you can see
around line#2118 in SWIG's generated mapscript.php file, so you can
change "function __set" on that line to "function set"
Hope this helps.
Thanks again for your interest in MS4W.
-jeff
--
Jeff McKenna
MapServer Consulting and Training Services
https://gatewaygeomatics.com/
On 2019-02-14 5:30 AM, ludwig--- via MS4W-Users wrote:
> Hi Jeff,
> I hadn't read the FM, now included the mapscript.php-File and tested again with partial success.
>
> error 1 still exists
> ms_ResetErrorList();
> => "Fatal error: Uncaught Error: Call to undefined function ms_ResetErrorList()",
>
> error 2 disappeared
> $ms_map_obj = new mapObj('e:\website\wver_ims_bak\mapserver\blank.map');
> => no error, a "print_r($ms_map_obj)" shows a valid resource:
> mapObj Object
> (
> [_cPtr] => Resource id #3
> [_pData:protected] => Array
> (
> )
>
> )
>
> But new error 3:
> $ms_layer_obj = ms_newLayerObj($ms_map_obj);
> => Fatal error: Uncaught Error: Call to undefined function ms_newLayerObj()
>
> I would keep on testing, but Mapserver without layer...
>
> Ludwig
>
>
>
> Gesendet: Montag, 11. Februar 2019 um 16:25 Uhr
> Von: "Jeff McKenna via MS4W-Users" <ms4w-users at lists.ms4w.com>
> An: ms4w-users at lists.ms4w.com
> Cc: "Jeff McKenna" <jmckenna at gatewaygeomatics.com>
> Betreff: Re: [MS4W-Users] ms4w 4.0.0 PHP-Mapscript Test
> Hi Ludwig,
>
> Thank you for your feedback.
>
> As there are many changes as part of MS4W 4, be sure to always first
> check the documentation that is part of your local install: eg. for
> PHPmapscript see locally http://127.0.0.1/README_INSTALL.html#php
>
> Make sure to follow all of the steps listed there, especially #5 to
> include the required file; I will paste those steps here for you to follow:
>
> MapScript configuration
> =======================
>
> PHP
> ---
>
> .. WARNING::
>
> As of the MS4W 4.0.0 release, PHPMapScript uses the `SWIG MapScript
> API <https://mapserver.org/mapscript/mapscript.html[https://mapserver.org/mapscript/mapscript.html]>`__.
>
> 1. PHPMapScript dll is located in ``/ms4w/Apache/php/ext``
>
> 2. PHP's configuration file "php.ini" is located in ``/ms4w/Apache/cgi-bin``
>
> 3. PHPMapScript is loaded by default
>
> 4. As of the MS4W 4.0.0 release, the PHPMapScript extension uses the
> SWIG MapScript API
> (see SWIG MapScript API docs at
> https://mapserver.org/mapscript/mapscript.html[https://mapserver.org/mapscript/mapscript.html])
>
> 5. All of your PHP scripts must now always first include the
> ``mapscript.php`` file
> containing MapServer constants:
>
>
> // required SWIG include (contains MapServer constants for PHP7)
> include("C:/ms4w/apps/phpmapscriptng-swig/include/mapscript.php");
>
> 6. Test this syntax with the provided quickmap.php file at
> ``/ms4w/Apache/htdocs/quickmap.php``
> (see usage instructions in the top of that file)
>
>
>
> Thank you for your interest in MS4W.
>
> -jeff
>
>
>
> On 2019-02-11 6:09 AM, ludwig--- via MS4W-Users wrote:
>> Hi List,
>> I installed a fresh version ms4w_4.0.0_beta1, Apache starts, phpinfo
>> shows "MapServer version 7.4.0-dev (MS4W 4.0.0)", looks fine, but the
>> first test of php-mapscript-functions had no success:
>> ms_ResetErrorList();
>> => "*Fatal error*: Uncaught Error: Call to undefined function
>> ms_ResetErrorList()"
>> $ms_map_obj = new mapObj('e:\website\wver_ims_bak\mapserver\blank.map');
>> => *"Fatal error*: Uncaught Error: Class 'mapObj' not found"
>> Stopped further testing. Allthough phpinfo says, mapscript is available,
>> the mapscript-functions and -classes aren't recognized.
>> By the way, same Scripts on debian (PHP 7.2 and MapScript MapServer
>> version 7.3-dev) run without problems...
>>
>> _
>
>
More information about the MS4W-Users
mailing list