I am in windows 7. I installed WAMPServer. Now, I can not load spatialite libraries. It is showing warning..
Warning: SQLite3::loadExtension() [sqlite3.loadextension]: Not
supported in multithreaded Web servers
Here is my total configuration procedure, what I have done...
From this link I got spatialite lib. I copied "libspatialite-1.dll" and paste it to "D:\wamp\bin\php\php5.3.8\ext" which contains php extention dlls.
http://www.gaia-gis.it/spatialite-2.3.1/libspatialite-win-x86-2.3.1.zip
Then I edited php.ini file. I changed the following configuration.
.
sqlite3.extension_dir = C:\libspatialite-win-x86-2.3.1\bin
.
extension=libspatialite-1.dll
.
enable_dl = On
And lastly, I copy and paste all the libraries from my downloaded libspatialite-win-x86-2.3.1 to my project folder(libspatialite.a, libspatialite.dll.a, libspatialite.la) in my php code i write the script as follows...
<?php
$db = new SQLite3('sixcommunes.sqlite');
$db->loadExtension('libspatialite.a');
$rs = $db->query('SELECT spatialite_version()');
while($row = $rs->fetchArray()){
print "<h3>SQLite version: $row[0]</h3>";
}
?>
I do not know what I have done wrong or how to solve this problem?
Haven't seen any answer, so giving my own. I have used spatialite in C#, I think for using Spatialite Extensions you don't have to load libspatialite like a usual PHP extension, instead something similar to this should be done. (this is c# code, just trying to give you an idea)
SQLiteCommand sqliteCommand = new SQLiteCommand(String.Format("SELECT
load_extension('{0}');", "libspatialite-2.dll"), connection);
sqliteCommand.ExecuteNonQuery();
You have to execute Select load_extension("libspatialite-2.dll") on sqlite to use Spatialite.
Hope this helps
Related
I tested a simple Php program using Sqlite3 instead of mySQL on my own computer and it works fine. What the program does is simple insert of record into a certain table. Now, when I try to do that on a remote web server running on Linux (CentOS) with Sqlite3 enabled it does not work.
I thought at first it was simply a file permission issue since my Sqlite file had an initial permissions of 644 so I changed it to 646 then 767 both to no avail.
The Php version by the way on web server is a little bit dated, namely, Php 5.1.6 but on my local PC it is 5.5.11.
This is the sample code that I ran on both servers.
$db = new PDO('sqlite:test.db');
$lastname = "Doe";
$firstname = "John";
$sql = "INSERT INTO people (Lastname,Firstname) VALUES (:lastname,:firstname)";
$q = $db->prepare($sql);
$q->execute(array(':lastname'=>$lastname,
':firstname'=>$firstname));
I tried a simple query on a sqlite3 database on the webserver by the way and it works.
So, could this be a simple Php version issue?
I cannot by the way change the php.ini so forgo that possible direction for the moment. And I don't have any choice of having a new Php version on that server since I use it for free.
Is there any way to have Cassandra PDO at Windows with Wamp?
This is for development purposes I don't want to install Linux and change all the environment.
https://code.google.com/a/apache-extras.org/p/cassandra-pdo/
I'm using Windows 7 (64 Bit), Wamp 2.5, PHP 5.5.
OK, here's what I found out:
1) It's totally possible
2) The docs that appear in the first google search results are a bit obsolete
Start by downloading the latest Datastax Community Cassandra here:
http://planetcassandra.org/cassandra/
Install & setup properly. In fact, most of the configuration is done by the installer, you just have to edit the apache-cassandra/conf/cassandra.yaml file to find all paths to /var/lib... and change those into something like d:/cassandra/... That includes "commitlog", "data", "saved_caches". Restart the Cassandra service, examine the logs. Mine shown no problem. The OpsCenter at ...:8888/opscenter/index.html was working fine, showing one node online.
Now, the PHP part.
There's a sneaky thing called Thrift. From what I've learned today (I first heard about Cassandra and Thrift yesterday), it's a way describe a binary protocol of connecting to some online service, in this case, to Cassandra. It will basically generate PHP files that will provide all the connectivity you need from PHP itself (no extensions needed).
You will need:
1) The Thrift PHP libs
2) The .exe Thrift compiler
Both can be downloaded here:
https://thrift.apache.org/download
Then use the following command to compile PHP files that will act as a "driver" to connect your PHP applications to Cassandra:
thrift --gen php D:\DataStaxCommunity\apache-cassandra\interface\cassandra.thrift
Put the result in some PHP include_path folder.
Also, find the PHP Thrift libs (in the libs archive from the same download page) and put those in a folder accessible to your script (e.g. include_path or the project folder).
Refer this page:
thrift.apache.org/lib/php
I guess that should help!
I have same problem as you, but when i tried this method, it works correctly for me.
Reference link
Here is a code example, very easy to understand :
<?php
require_once 'Cassandra/Cassandra.php';
$o_cassandra = new Cassandra();
$s_server_host = '127.0.0.1'; // Localhost
$i_server_port = 9042;
$s_server_username = ''; // We don't use username
$s_server_password = ''; // We don't use password
$s_server_keyspace = 'cassandra_tests';
$o_cassandra->connect($s_server_host, $s_server_username, $s_server_password, $s_server_keyspace, $i_server_port);
$s_cql = "CREATE TABLE carles_test_table (s_thekey text, s_column1 text, s_column2 text,PRIMARY KEY (s_thekey));";
$st_results = $o_cassandra->query($s_cql);
I followed the directions on the readme file but I didn't get any errors nor any output or anything written to the log file.
so, what is the right way of converting and HTML file to PDF with prince, thank you in advance.
ini_set('display_errors', '1');
error_reporting(-1);
require 'prince.php';
$exepath='/Users/agk/Desktop/prince/bin/prince';
$prince= new Prince($exepath);
if(!$prince) die("Prince instantiation failed");
$prince->setHTML(TRUE);
$prince->setLog('prince.log');
$xmlPath='/Applications/MAMP/htdocs/test/newhtml.html';
$msgs= array();
$convert=$prince->convert_file($xmlPath, $msgs);
if(!$convert)
{
echo 'nothing converted';
var_dump($msgs);
}
I notice you are using MAMP - and this is where I hit the same issue - and here's how I fixed it.
I managed to find an answer elsewhere on SO relating to running shell commands via PHP on MAMP, so will share this.
The problem is that the DYLD_LIBRARY_PATH is set in MAMP, and the shell/shell_exec command in PHP is looking elsewhere.
As explained in the original post, this might not be the best fix but it has me up and running for now - and the alternative suggestions there didn't work for me.
So, try this:
Open the /Applications/MAMP/Library/bin/envvars file and comment the following lines as below:
#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH
then restart Apache
It might mess up other MAMP settings, but I can live with that for now, as I need this to work locally on my Mac for testing before I load it all on a live Linux server.
Hope this helps.
I have an application I want to package as a PHAR with both CLI and web interfaces (it acts as an API to wider system so I'd like to avoid reproducing the same libraries across two PHAR archives). The 'bug' im encountering is that the PHAR always acts like it's run from the command line when created with createDefaultStub.
<?php
try {
$phar = new Phar('myphar.phar');
$phar['cli.php'] = '<?php echo "CLI"; ?>';
$phar['web.php'] = '<?php echo "Web"; ?>';
$phar->setDefaultStub('cli.php', 'web.php');
// this is the same as:
// $phar->setStub($phar->createDefaultStub('cli.php', 'web/index.php'));
} catch (Exception $e) {
// handle errors
}
?>
If I run the phar created from the above code which was taken directly from (http://www.php.net/manual/en/phar.createdefaultstub.php from the command line with
php.exe myphar.phar
I see, "CLI" as expected, but I also see this from the web also.
There is a documented bug from 2010, but since it appears unsolved and not many cases available I'm wondering if its something I'm doing wrong at my end.
PHP Bug Report: https://bugs.php.net/bug.php?id=52322&edit=2
Things I've done to try and diagnose:
Tested on PHP 5.4.11, 5.3.21, 5.2.17
The phar was recreated under each version also.
Tried on a clean install of the latest XAMPP.
PHP.ini settings
detect_unicode = Off
phar.readonly = Off
phar.require_hash = Off
Debugged with echo from cli.php of:
$_SERVER['REQUEST_URI']
$_SERVER['REQUEST_METHOD']
Both return as expected, these are the values used in the default stub to check if it's running on the web.
I really am at a loss here and wondered if anybody had ideas about where to turn next?
Writing a custom stub is an option, but likely something is going wrong behind the scenes that will trip me up later on.
Any advice would be greatly appreciated :)
Do you know how can I call an ASP.NET .dll file from a PHP script?
Thanks!
You use the DOTNET extension.
First off, you need to be running this on Windows. If you are on linux, then I would look at using something like Facebooks Thrift.
If you are on windows and depending on which build of windows you are using you may need to uncomment the com extension in your php.ini
<?php
$stack = new DOTNET("mscorlib", "System.Collections.Stack");
$stack->Push(".Net");
$stack->Push("Hello ");
echo $stack->Pop() . $stack->Pop();
?>
Here are a list of Windows Specific functions