I am developing a custom application in PHP for Mdaemon Mail Server. There are no API samples in PHP, all are in CPP and VB.
I know that we can work with dll in files in PHP using COM and I am also in windows environment. To get everything started I need to load MDUser.dll file.
So far I have downloaded php_com_dotnet.dll and have placed it in extensions directory in my wamp server C:\wamp\bin\php\php5.3.13\ext. I have enabled the extension in php.ini extension=php_com_dotnet.dll
This is my code
$oMDUser = new COM("MDUserCOM.MDUser") or die("Unable to instantiate MDUSER COM object");
This line throws an error.
Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object MDUserCOM.MDUser' in C:\wamp\www\mdaemon\test.php on line 20
( ! ) com_exception: Failed to create COM objectMDUserCOM.MDUser': Invalid syntax in C:\wamp\www\mdaemon\test.php on line 20
Actually I don't know what MDUserCOM.MDUser refers to. How should I instantiate the COM class. Ex $obj = new COM("Application.ID") and what is application and ID in my scenario.
I haven't worked with dll files before. Where I am going wrong and where should I place MDUser.dll file. Anyway it is in my working directory.
Thanks in advance
Related
I converted a Laravel project into PC Software (setup.exe) with live Database MySQL, using PHP Desktop chrome and Inno Setup but when opening the executable an error was generated:
Fatal error: Declaration of Illuminate\Container\Container::get($id) must be compatible with Psr\Container\ContainerInterface::get(string $id) in C:\Program Files (x86)\Data Management App\www\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 16
What is the reason for that error please and how can I solve it?
Recently, I formated my whole computer, and installed Windows 7 64-bit. Before doing that I saved all of my files on an external hard drive. One of the things I backed up was a PHP script which uses AWS DynamoDB Services.
Before I formated my computer, everything went perfect. After I formated it, I installed on it XAMPP, Visual Studio Code, and PHP 7.1.1 through Microsoft WebPI.
Currently when I'm trying to run my PHP script I get this error on my screen:
Warning: require(/zip/aws/aws-autoloader.php): failed to open stream: No such file or directory in D:\Users\Lenovo\xampp\htdocs\public_html\file.php on line 7
Fatal error: require(): Failed opening required '/zip/aws/aws-autoloader.php'(include_path='D:\Users\Lenovo\xampp\php\PEAR') in D:\Users\Lenovo\xampp\public_html\file.php on line 7
I'm calling the autoloader this way:
require '/zip/aws/aws-autoloader.php';
I'm trying to understand if I forgot to install another thing, or if it's something related to the system (I had Windows 10 before)...
Could you please help me figure it out? I'm pretty new to this topic of PHP...
You should specify the entire path, like this: require __DIR__ . '/zip/aws/aws-autoloader.php';
I know there are tons of questions about this on SO. But I've been trying to fix this since a month with no luck.
At work we have this very old website that uses an access database, and I cannot do anything about it.I want to work on some changes on my local PC using wamp server. So I donwloaded the website along with the db. Here is how it's supposed to connect :
$conn = new COM('ADODB.Connection');
$db = realpath("dbalerts.mdb");
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
But it's giving me this error:
Fatal error: Uncaught exception 'com_exception' with message 'Source: ADODB.Connection
Description:Provider cannot be found. It may not be properly installed.'
in C:\wamp\www\testaccess\index.php:5 Stack trace: #0 C:\wamp\www\testaccess\index.php(5): com->Open('Provider=Micros...') #1 {main} thrown in C:\wamp\www\testaccess\index.php on line 5
It's a test folder whith an index.php where only that code is written. In the same folder is dbalerts.mdb
I tried everything I know. I downloaded AccessDatabaseEngine.exe from MS website which is supposed to have the driver. And it installed properly with no errors( had to uninstall office because it was 64bit)
I am on a win8 machine
Any ideas how I can fix this all while still using COM and ADODB? Because I can't go through changing the connections of every .php file in that website (it's old and poorly designed so not adaptable to changes)
I am attempting to use https://github.com/amzn/amazon-instant-access-sdk-php for amazon instant access via php. I am not super familiar with phar files; but am starting to figure it out.
I included https://github.com/amzn/amazon-instant-access-sdk-php/blob/master/phar-stub.php in a file as shown below. (Modified a bit as I renamed phar file)
Phar::mapPhar('amazon-instant-access-sdk-php.phar');
require_once 'phar://amazon-instant-access-sdk-php.phar/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php';
$classLoader = new Symfony\Component\ClassLoader\UniversalClassLoader();
$classLoader->registerNamespaces(array(
'Amazon' => 'phar://amazon-instant-access-sdk-php.phar/src',
'Psr' => 'phar://amazon-instant-access-sdk-php.phar/vendor/psr/log',
'Monolog' => 'phar://amazon-instant-access-sdk-php.phar/vendor/monolog/monolog/src'
));
$classLoader->register();
return $classLoader;
__HALT_COMPILER();
Then when I do in another file:
require_once('amazon-instant-access-phar-stub.php');
I get error:
Fatal error: Uncaught exception 'PharException' with message 'internal corruption of phar "/Applications/MAMP/htdocs/phppos/amazon-instant-access-phar-stub.php" (truncated manifest at stub end)' in /Applications/MAMP/htdocs/phppos/amazon-instant-access-phar-stub.php:17 Stack trace: #0 /Applications/MAMP/htdocs/phppos/amazon-instant-access-phar-stub.php(17): Phar::mapPhar('amazon-instant-...') #1 /Applications/MAMP/htdocs/phppos/amazon_link_account.php(3): require_once('/Applications/M...') #2 {main} thrown in /Applications/MAMP/htdocs/phppos/amazon-instant-access-phar-stub.php on line 17
I have tried re-downloading phar file and running different versions of php (5.3, 5.6)
I am not sure what is causing this error.
You could directly download the .phar file from the release.
If you have the .phar file, you don't need the source code from github. The source code on github is used to compile the .phar file.
In your php code, you could do something like this:
<?php
//import the phar file directly like you did
require_once('amazon-instant-access-sdk-php.phar’);
//before you initiate the class, you need to use the right name space:
use Amazon\InstantAccess\Signature as signature;
$credentialStore = new signature\CredentialStore();
?>
This one will work.
If you want to check exactly what's in the .phar file, you could extract it:
php -r '$phar = new Phar("amazon-instant-access-sdk-php.phar"); $phar->extractTo("/tmp/phar/");'
then you could browse the /tmp/phar/ for all the files in the .phar.
While working with PHPExcel in my application I got following errors
In PHPExcel/Autoloader.php file for line “PHPExcel_Shared_ZipStreamWrapper::register();”,
Fatal error: require() [function.require]: Failed opening required '/wamp/www/xxxx/site//common/class/PHPExcel_Shared_ZipStreamWrapper.class.php' (include_path='C:\wamp\www\xxxx\site\common\html_purifier;.;C:\php\pear') in C:\wamp\www\xxxx\site\config\bootstrap.php on line 27
and for line “PHPExcel_Shared_String::buildCharacterSets();”
Fatal error: require() [function.require]: Failed opening required '/wamp/www/xxxx/site//common/class/PHPExcel_Shared_String.class.php' (include_path='C:\wamp\www\xxxx\site\common\html_purifier;.;C:\php\pear') in C:\wamp\www\xxxx\site\config\bootstrap.php on line 27
I'm using wamp with php 5.3.5. and zip xml and gd2 extensions are enable on my local machine.
Please help me for this.
Thanks.
The reference to C:\wamp\www\xxxx\site\config\bootstrap.php suggests you're working with some kind of framework: does it have an autoloader that could be conflicting with or overriding PHPExcel's autoloader?
The reference to
'/wamp/www/xxxx/site//common/class/PHPExcel_Shared_ZipStreamWrapper.class.php'
seems to confirm this.
as something is changing the filename to include ".class" as part of the filename, and it's ignoring PHPExcel's own autoloader that splits a class name to match its directory structure
If you're using a standard framework such as ZF or Symfony, then you should register PHPExcel with that framework. If it's a homebrew, make sure your autoloader is SPL registered
You seem to be having double slashes in your path:
/wamp/www/xxxx/site*//*common
So it's probably a path issue and the autoloader isn't able to load the file because the path is wrong.