1

I am running Windows Server 2008 32-bit, PHP 5.4.5, and Apache 2.2.22. I'm pretty sure COM is built-in to PHP core, but when I run the code to call a new COM object, I get a "Class 'COM' not found' error. The COM object I am calling is Microsoft Word, which is installed.

The code:

$word = new COM("word.application") or die("Could not initiate Word COM Object.");

PHP just spits out the error as described above.

7
  • 4
    Chances are you don't have the 'com' module compiled, hit the phpinfo page and see if it's there. Commented Aug 9, 2012 at 22:11
  • Mike you are right - it is not in PHPInfo - but how is this possible? All I did was download the ZIP file from PHP's website and extract it onto my disk. How do I get a binary that has COM compiled within it? I thought COM was a standard class as part of PHP Core as described here - php.net/manual/en/com.installation.php Commented Aug 9, 2012 at 22:16
  • 2
    From the comments here: From PHP 5.4.5, COM and DOTNET is no longer built into the php core.you have to add COM support in php.ini. (It does look like that PHP page needs updating - would you consider raising a bug ticket, Freddie?) Commented Aug 9, 2012 at 22:18
  • @halfer Please post that as an answer, this might be helpful for other users! Commented Aug 9, 2012 at 22:19
  • Thanks halfer - good find. +1 Commented Aug 9, 2012 at 22:24

2 Answers 2

7

From the user comments on the PHP website:

From PHP 5.4.5, COM and DOTNET is no longer built into the php core. You have to add COM support in php.ini.

Sign up to request clarification or add additional context in comments.

Comments

1

It's worth noting that this also exists from 5.3.15 and above, going by the below from the user comments:

As of 5.3.15 (if you are still on 5.3 branch) you have to add extension=php_com_dotnet.dll line into your php.ini to have COM, DOTNET, VARIANT and similar classes available and working.

From PHP Change log:

COM

    Fixed bug #62146 com_dotnet cannot be built shared

Because of this, the official PHP builds for Windows are now built with "--enable-com-dotnet=shared" option, which means no COM/DOTNET support by default.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.