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
Related
How do I use PHP 8.0 to determine the Apache installation path in a Windows environment?
No: I know where it is manually, I need to do this programmatically.
There was nothing in $_SERVER and I had to resort to digging through phpinfo(). The following allows you to reuse phpinfo() as $pinfo if you need to find other bits of information. Additionally PHP does not support the JavaScript index style (e.g. explode()[index]) on I think 7.2 and older so anyone stuck on those older versions may have to re-code the two explode in to separate lines.
//If you need additional items you can refer ONCE to $pinfo:
ob_start();
phpinfo();
$pinfo = ob_get_contents();
ob_end_clean();
if (PHP_OS == 'WINNT')
{
//explode()[index] will not work on PHP ~7.2 and older
echo explode('<', explode('>Server Root </td><td class="v">', $pinfo, 2)[1], 2)[0];
}
How can i copy a file/directory with PHP to a MAC machine?
So from
/home/domain/file/file.jpg
to
standalone macmachine directory
You can use the php copy function. read the following article.
function.copy.php
for example:
<?php
copy('/Your/Path/From', '/Your/Path/To');
//OR
copy('http://example.com/your_path', '/Your/Path/To');
copy('/Your/Path/From', '/Your/Path/To');
//OR
copy('http://example.com/your_path', '/Your/Path/To');
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 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
I'm using xampp.
I search and it looks like for php 4.x, there was an extension called php_w32api.dll which seems to have vanished for php 5.x. Nevertheless, it's still in the documentation on php.net but marked as experimental.
Some suggested to use win32std in pecl instead, but that just wraps some function of the win32 api, but doesn't allow me do call my own dll functions. :/
There is ffi, but the link on the pecl site is dead and it seems like development has stopped in 2004.
Any idea how to do this without writing my own php extension?
Best regards
Marc
COM functions are only available for the Windows version of PHP.
.Net support requires PHP 5 and the .Net runtime.
No installation needed to use these functions; they are part of the PHP core.
First create your ActiveX dll (Visual Basic):
Name your project as "foo" and class as "bar".
'---start VB code---
Public Function hello() As String
hello = "Hello World!"
End Function
'---end VB code---
Then make the dll and register it with regsvr32.exe
Now create your PHP script:
<?php
$obj = new COM("foo.bar");
$output=$obj->hello(); // Call the "hello()" method
// once we created the COM object this can be used like any other php classes.
echo $output; // Displays Hello World! (so this comes from the dll!)
?>