Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Class 'COM' not found PHP. Win7 - Apache - PHP

Tags:

php

windows

com

$myapp = new COM("word.application");
// returns a fatal error: "Class 'COM' not found in c:/www/comConnector.php"

shell_exec("whoami");
//returns "NT authority/system"

My system setup

  • Win7 Pro
  • Apache Server version: Apache/2.2.23 (Win32)
  • PHP

    PHP 5.3.16 (cli) (built: Aug 15 2012 20:06:57)
    Copyright (c) 1997-2012 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

like image 400
e-Learner Avatar asked Oct 08 '12 11:10

e-Learner


2 Answers

Add COM support in php.ini:

 [COM_DOT_NET]
     extension=php_com_dotnet.dll
like image 108
Radu Bompa Avatar answered Oct 13 '22 20:10

Radu Bompa


Since you are using PHP 5.3.16, make sure that you are pointing to the global namespace:

$myapp = new \COM("word.application");

Even though your PHP file might be in global namespace already, but it's a good practice.

like image 43
Mehran Avatar answered Oct 13 '22 19:10

Mehran