# How to compile or find PHP MapScript (MapServer) latest version for Windows?

I had major performance difficulties with MapServer version 6.0.3 (MS4W 3.0.6) and need latest version of MapScript but I can't find it for Windows.

Anybody can help me to find latest compiled (binary) of MapScript(PHP) or compile it from source for Windows?

I didn't find any compiled php_mapscript for any current PHP as well, so I tried to compile it myself. Took me long time and a lot of failures but I did it.

Don't know if you need this any more since your post is more than one year old but I have php_mapscript.dll built against php-5.6.27-win32-vc11-ts-x86 and Mapserver-7.0-vc11-x86 (stable branch package for 7-0 from gisinternals) now.

The short story to get the php_mapscript.dll is:

Build php as descriped in documentation on php website. I have my php-sdk at C:\dev\work\php-dev. Download gisinternals sdk and extract everything to C:\gisinteralssdk. Unpack everything into the same directory to get directories bin, doc, gdal, include, lib, mapserver, regex-0.23, release-1700 and SWIG-1.3.39 inside C:\gisinteralssdk\.

I have cloned the mapserver repository on github and applied the changes, needed for me to successfully compile php-mapscript to https://github.com/AlexanderGabriel/mapserver. At this point, you dan decide to merge the changes of branch branch-7-0-fixphpmapscriptwin32buildwithcmake to the mapserver-sources to be on official repository or just clone the repository with git clone https://github.com/AlexanderGabriel/mapserver/ C:\gisinteralssdk\mapserver.

I just opened a pull-request and hope they include it to future releases.

These commands will do the rest:

cd C:\gisinteralssdk\mapserver mkdir build cd build cmake .. -G "NMake Makefiles" -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -Wno-dev -DCMAKE_PREFIX_PATH=C:\gisinteralssdk;C:\gisinteralssdk\bin;C:\gisinteralssdk\lib;C:\gisinteralssdk\include -DREGEX_DIR=C:\gisinteralssdk\regex-0.12 -DWITH_SOS=1 -DWITH_KML=1 -DWITH_CLIENT_WMS=1 -DWITH_CLIENT_WFS=1 -DWITH_THREAD_SAFETY=1 -DWITH_FCGI=1 -DWITH_CAIRO=1 -DCAIRO_LIBRARY=C:\gisinteralssdk\lib\cairo.lib -DWITH_SVGCAIRO=1 -DSVGCAIRO_LIBRARY=C:\gisinteralssdk\lib\libsvg-cairo.lib -DSVG_LIBRARY=1 -DSVG_LIBRARY=C:\gisinteralssdk\lib\libsvg.lib -DWITH_POSTGIS=0

Test if it works with nmake. Then enable php:

cmake .. -DWITH_PHP=1 -DPHP5_INCLUDES=C:\dev\work\php-dev\phpdev\vc11\x86\php-5.6.27-src -DPHP5_EXTENSION_DIR=C:\gisinteralssdk

And finally build PHP-MapScript with nmake.

Don't know, if you are familar with CMake. Choose your needed Options. PostGIS works if you install PostGIS on your system and add the path to the \bin-directory to you systems oder users PATH variable before starting CMake the first time.

From this point, it's easier to change any library to a different version or change CMake-options to enable a needed feature. It took me several days to compile mapscript the first time (didn't know if i can do this at all) but then i started to reduce work to this few steps. In my Opinion, it totally crazy and unnecessary to compile all the dependencies from scratch. Different Build-Systems, a lot to read, do and test. If you want, you can have my notes about that but i will not do it that way once again ;)

The PHP build process is really straightforward. Exactly as described on https://wiki.php.net/internals/windows/stepbystepbuild.

Because i'm not that experienced in this Windows-Build-Stuff, i'm not sure, if everything i changed is good. So please test, test, test, before using that in production.

Hope, this helps you to build your PHP-Mapscript. Any feedback is welcome.

PS: I could compile php-mapscript 'on Windows' with the new "Linux Subsystem"-Feature of Windows 10 in a few minutes. There are even packages in the repositories so you can install with apt-get. You can install an Apache there and start it. It will listen on 'localhost' of your Windows-Machine. Crazy but it works and you can access Mapfiles on C or any other drive from there. So if you only want to use Windows for developement, this maybe an option. But not for production yet.

UPDATE 2017-01-04: Mapserver project merged my pull-request on github. Version 7.0.3 contains all patches but no updated documentation. In the current, branch, there is already a new documentation in README.WIN32 for both, Mapserver and PHP/MapScript so you can use the documentation there to build Mapserver with PHP/MapScript on Windows

• thanks for your answer it would be very nice of you if describe for us your compilation process it can help me and others too mach and maybe help for other extensions too. – MSS Nov 6 '16 at 5:57
• I will be able to explain (without writing a book) soon. forked mapserver on github today to upload my patches to source, build-system and documentation. i think, this would help most. Please give me a few days to prepare everything. i will then edit my answer above – Alex Nov 8 '16 at 19:51
• You are doing a great job. I will wait for it hopefully. – MSS Nov 9 '16 at 7:30
• i already edited. look above. – Alex Nov 9 '16 at 19:54

Since you posted your question MapServer for Windows (MS4W) have released a new version, which provides version 7 of MapServer, and MapScript support for PHP, Python, Java, and CSharp.

An alternative source of Windows Binaries for MapServer (with Mapscript support) can be found from GISInternals