Use spatialite with php

137 views
Skip to first unread message

Guen LM

unread,
Sep 1, 2021, 4:30:51 PM9/1/21
to SpatiaLite Users
Hello,
I tried this https://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/php.html to use spatialite with php but I can't find libspatialite.so or mod_spatialite.so on my server (i install apt-get install libsqlite3-mod-spatialite) or on internet.
where can I find it ?
Thank's
guen

Alessandro Furieri

unread,
Sep 2, 2021, 12:18:51 PM9/2/21
to SpatiaLite Users
Hi Guen,

you completely missed to specify which operating system is installed on your server.
I'll assume it will probably be some version of Debian (apt-get)

what do you exactly indent when you say "I can't find libspatialite.so or 
mod_spatialite.so on my server after apt-get install libsqlite3-mod-spatialite" ?

apt-get will usually install mod_spatialite.so on /usr/lib/x86_64-linux-gnu
that is a standard system directory for installing packaged libraries and
modules and is usually covered by platform system-wide rules for searching 
and loading dynamic libraries and modules.

you can easily check if mod_spatialite.so has been really installed or not
by executing this simple command on the shell:

ls -l /usr/lib/x86_64-linux-gnu/mod_spatialite*

that said: PHP will probably forbid to load a generic extension for
security reasons if it's not installed within some "special" location
defined in the php.ini configuration script.

you can find more detailed instructions on the tutorial in the paragraph 
"Configuring PHP"

note: the tutorial was written about 5 year ago. I completely ignore
if the PHP configuration of more recent versions has changed someway
in the meanwhile.

bye Sandro

Guen LM

unread,
Sep 3, 2021, 2:42:59 AM9/3/21
to SpatiaLite Users
hello
Oups, I forgot to tell that  I am on Ubuntu and yes, I found the so in the path you gave me (I was looking for libspatialite.so and not mod_saptialite.so...).
It works fine when I use $db = new SLITE3($path) and loadExtension .
I am on a Joomla's composant so I would like to use JDatabaseDriver::getInstance() but loadExtension doesn't work here...but it's a php's problem and not a spatialite problem !
Thank's a lot !
Guen

Andrea Peri

unread,
Sep 3, 2021, 3:00:37 AM9/3/21
to spatiali...@googlegroups.com
Afaik the loadextension should work. Indont know pho but inguess it is no more different from python or java.
I know surely is possible to do a loadextension on java in a jsp page. So why not in php ?

Instead i know the loadextension should be enabled at compile time.
So you could have a sqlite with a loadextension disabled.

A.


--
You received this message because you are subscribed to the Google Groups "SpatiaLite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialite-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spatialite-users/7a75221c-c3be-485f-ab2d-7096d0c67e45n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages