Freddie
Freddie

Reputation: 741

PHP Class 'COM' not found

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.

Upvotes: 1

Views: 4015

Answers (2)

Aaron Mason
Aaron Mason

Reputation: 350

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.

Upvotes: 1

halfer
halfer

Reputation: 20439

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.

Upvotes: 7

Related Questions