[英]Xampp PHP Create COM Object Fatal Error without any info
I'm running into a problem with my php application. 我的php应用程序遇到了问题。 I'm building up a service application which should be connected to our ERP ( selectline ). 我正在构建一个服务应用程序,该应用程序应连接到我们的ERP(selectline)。
But I can't get to create a COM Object. 但是我无法创建一个COM对象。 This code: 这段代码:
<?PHP
error_reporting(E_ALL);
session_start();
date_default_timezone_set('Europe/Zurich');
echo time();
$obj = new COM("fd6c8b29-e936-4a61-8da6-b0c12ad3ba00") or die("Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}\n";
?>
Returns me: 返回我:
Fatal error: in C:\\xampp\\htdocs\\com.php on line 21 致命错误:在第21行的C:\\ xampp \\ htdocs \\ com.php中
I got two environments: 我有两种环境:
Server 2008 R2 + Xampp v3.1.0 |PHP 5.4.7 Server 2008 R2 + Xampp v3.1.0 | PHP 5.4.7
Server 2012 R2 + Xampp v3.1.0 | Server 2012 R2 + Xampp v3.1.0 | PHP 5.4.7 PHP 5.4.7
I had to add the php_com_dotnet.dll in the php.ini because I had COM class not found before. 我必须在php.ini中添加php_com_dotnet.dll,因为以前没有找到COM类。
Due to the fact I'm complete new to COM I have no idea where to search for the failure. 由于我是COM的新手,所以我不知道在哪里搜索失败。
May you guys can help me out. 希望你们能帮助我。
Thanks in advance 提前致谢
I changed my code a bit: 我对代码做了一些更改:
try {
$obj = new COM("word.application") or die("Unable to instantiate Word");
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
Now I get: 现在我得到:
Failed to create COM object `word.application': Invalid Syntax 无法创建COM对象`word.application':无效的语法
I don't get what is wrong. 我不明白有什么问题。 According to this article http://www.php.net/manual/en/class.com.php there is no need for additional parameters, right? 根据本文http://www.php.net/manual/zh/class.com.php ,不需要其他参数,对吗?
Make sure to set the correct COM permission to "This User". 确保将正确的COM权限设置为“此用户”。
I hope I save lots and lots of hours of headaches to some of you :) 我希望我为你们中的许多人省去了很多麻烦的时间:)
PHP Setup PHP设置
extension=php_com_dotnet.dll 扩展名= php_com_dotnet.dll
Usage 用法
<?php
try {
$word = new COM("word.application");
} catch (Exception $ex) {
echo $ex->getMessage();
exit;
}
$word->Screenupdating = true;
$word->WindowState = 2;
$word->Visible = 0;
$word->CheckLanguage = false;
$word->Options->Overtype = false;
$word->Options->SaveInterval = 0;
$word->Assistant->Visible = false;
$word->DisplayAlerts = false;
// Do fancy stuff...
// Close word
$word->Quit();
$word = null;
Have you tried giving Apache service admin rights in services.msc ? 您是否尝试过在services.msc中给Apache服务管理员权限?
It will require that you have a password on the account you're using to run it, though. 不过,这将要求您在用于运行该帐户的帐户上输入密码。 Hope that helps.. 希望有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.