3

So, this PR opens up mapscript support for PHP7. Since there is no ducomentation I gave it a try based on How compile/install php-mapscript on Ubuntu 16.04 (although I'm doing it in Debian 9 if that's important).

Here's what I did:

apt-get install apache2
#install PHP (PHP7.0 at the time of writing)
apt-get install php
#PR is on the master branch
wget https://github.com/mapserver/mapserver/archive/master.zip
unzip master.zip
#install cmake
apt-get install cmake
#make build directory and change to it [~/mapserver-7.0.2/build]:
mkdir build
cd build
#install compile requirement
apt-get install libfreetype6-dev 
apt-get install php7.0-dev
apt-get install libproj-dev
apt-get install libfribidi-dev
apt-get install libharfbuzz-dev
apt-get install libcairo-dev
apt-get install libgdal-dev
apt-get install libgpg-error-dev
#config 
cmake -DCMAKE_INSTALL_PREFIX=/opt -DCMAKE_PREFIX_PATH="/usr/local:/opt" -DWITH_PROTOBUFC=0 -DWITH_CLIENT_WFS=ON -DWITH_CLIENT_WMS=ON -DWITH_CURL=ON -DWITH_SOS=ON -DWITH_PHP=ON -DWITH_FCGI=OFF -DWITH_PYTHON=OFF -DWITH_SVGCAIRO=OFF .. >../configure.out.txt
#compile
make

#install
make install

#enable mapscript and restart
echo extension=php_mapscript.so>/etc/php/7.0/mods-available/mapscript.ini
?
ln -s /etc/php/7.0/apache2/conf.d/mapscript.ini /etc/php/7.0/apache2/conf.d/mapscript.ini
?
phpenmod mapscript
service apache2 restart

make looks fine to me:

make
...
[ 98%] Building C object mapscript/php/CMakeFiles/php_mapscript.dir/php_mapscript_util.c.o
[ 99%] Building C object mapscript/php/CMakeFiles/php_mapscript.dir/php_mapscript.c.o
[100%] Building C object mapscript/php/CMakeFiles/php_mapscript.dir/mapscript_i.c.o
/home/deb9/ms72/mapserver/mapscript/php/mapscript_i.c: In function ‘mapObj_getMetaData’:
/home/deb9/ms72/mapserver/mapscript/php/mapscript_i.c:288:10: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   return(msLookupHashTable(&(self->web.metadata), name));
         ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deb9/ms72/mapserver/mapscript/php/mapscript_i.c: In function ‘layerObj_getMetaData’:
/home/deb9/ms72/mapserver/mapscript/php/mapscript_i.c:798:10: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   return(msLookupHashTable(&(self->metadata), name));
         ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[100%] Linking C shared module php_mapscript.so
[100%] Built target php_mapscript

make install looks pretty promising, too:

make install
...
[ 77%] Built target shptreevis
[ 78%] Built target msencrypt
[ 79%] Built target sortshp
[ 81%] Built target tile4ms
[100%] Built target php_mapscript
Install the project...
...
-- Installing: /opt/share/mapserver/cmake/mapserver-config-version.cmake
-- Installing: /opt/share/mapserver/cmake/mapserverTargets.cmake
-- Installing: /opt/share/mapserver/cmake/mapserverTargets-noconfig.cmake
>>>END

As you can see althought it says it builds php_mapscript it is not installing it at the end. Thus, /usr/lib/php/20151012 does not contain php_mapscript.so:

build         fileinfo.so  opcache.so   shmop.so      sysvshm.so    xmlwriter.so
calendar.so  ftp.so      pdo.so       simplexml.so  tokenizer.so  xsl.so
ctype.so     gettext.so   phar.so      sockets.so    wddx.so
dom.so         iconv.so      posix.so     sysvmsg.so    xmlreader.so
exif.so      json.so      readline.so  sysvsem.so    xml.so

phpinfo() obvioulsy does not list MapScript as a module. So this somehow did not work.

So, to cross-check this, I tried the same (well, almost obviously) with PHP5.6:

apt-get install apache2

apt-get install apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
apt-get update
apt-get install php5.6
update-alternatives --config php
(and select the item with PHP 5.6)  
a2dismod php7.0
a2enmod php5.6
service apache2 restart

wget http://download.osgeo.org/mapserver/mapserver-7.2.0.tar.gz
tar xvf mapserver-7.2.0.tar.gz
cd mapserver-7.2.0/

wget https://github.com/mapserver/mapserver/archive/branch-7-2.zip
unzip branch-7-2.zip
cd mapserver-branch-7-2
mkdir build
cd build

apt-get install libfreetype6-dev
apt-get install php5.6-dev
apt-get install libproj-dev
apt-get install libfribidi-dev
apt-get install libharfbuzz-dev
apt-get install libcairo-dev
apt-get install libgdal-dev
apt-get install libgpg-error-dev
apt-get install cmake

cmake -DCMAKE_INSTALL_PREFIX=/opt -DCMAKE_PREFIX_PATH="/usr/local:/opt" -DWITH_PROTOBUFC=0 -DWITH_CLIENT_WFS=ON -DWITH_CLIENT_WMS=ON -DWITH_CURL=ON -DWITH_SOS=ON -DWITH_PHP=ON -DWITH_FCGI=OFF -DWITH_PYTHON=OFF -DWITH_SVGCAIRO=OFF .. >../configure.out.txt
make
make install
echo extension=php_mapscript.so>/etc/php/5.6/mods-available/mapscript.ini
ln -s /etc/php/5.6/apache2/conf.d/mapscript.ini /etc/php/5.6/apache2/conf.d/mapscript.ini  
phpenmod mapscript
service apache2 restart

make looks just like the PHP7 try to me:

make
...
[ 98%] Building C object mapscript/php/CMakeFiles/php_mapscript.dir/php_mapscript_util.c.o
[ 99%] Building C object mapscript/php/CMakeFiles/php_mapscript.dir/php_mapscript.c.o
[100%] Building C object mapscript/php/CMakeFiles/php_mapscript.dir/mapscript_i.c.o
/home/deb9/Downloads/mapserver-branch-7-2/mapscript/php/mapscript_i.c: In function ‘mapObj_getMetaData’:
/home/deb9/Downloads/mapserver-branch-7-2/mapscript/php/mapscript_i.c:288:10: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   return(msLookupHashTable(&(self->web.metadata), name));
         ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/deb9/Downloads/mapserver-branch-7-2/mapscript/php/mapscript_i.c: In function ‘layerObj_getMetaData’:
/home/deb9/Downloads/mapserver-branch-7-2/mapscript/php/mapscript_i.c:798:10: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   return(msLookupHashTable(&(self->metadata), name));
         ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[100%] Linking C shared module php_mapscript.so
[100%] Built target php_mapscript

make install is similar but installs php_mapscript as well:

make install:
...
[ 77%] Built target shptreevis
[ 78%] Built target msencrypt
[ 79%] Built target sortshp
[ 81%] Built target tile4ms
[100%] Built target php_mapscript
Install the project...
...
-- Installing: /opt/share/mapserver/cmake/mapserver-config-version.cmake
-- Installing: /opt/share/mapserver/cmake/mapserverTargets.cmake
-- Installing: /opt/share/mapserver/cmake/mapserverTargets-noconfig.cmake
-- Installing: /usr/lib/php/20131226/php_mapscript.so
-- Set runtime path of "/usr/lib/php/20131226/php_mapscript.so" to "/opt/lib"
>>>END

/usr/lib/php/20131226 now contains php_mapscript.so:

build         ftp.so     pdo.so           shmop.so    tokenizer.so
calendar.so  gettext.so  phar.so       sockets.so
ctype.so     iconv.so     php_mapscript.so  sysvmsg.so
exif.so      json.so     posix.so       sysvsem.so
fileinfo.so  opcache.so  readline.so       sysvshm.so

phpinfo() lists MapScript as a module, just like in @MSS's post/screnshot in How compile/install php-mapscript on Ubuntu 16.04.

Any hints or ideas to get mapscript to work with PHP7? Is there some flaw in my workflow?

1

The install command is commented out in mapserver/master:

https://github.com/mapserver/mapserver/blob/master/mapscript/php/CMakeLists.txt#L46

install(TARGETS php_mapscript DESTINATION ${PHP_EXTENSION_DIR})

The bjoernboldt branch has this included. I'm not sure if this is due to issues with different destination directories for different PHP versions, or an oversight.

Could you try uncommenting and rebuilding?

  • I tried this and I think it was what made mapscript available. Is this an error which should be reported? – Worth Lutz Mar 5 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.