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

$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 PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

+6
source share
2 answers

Add COM support in php.ini:

  [COM_DOT_NET] extension=php_com_dotnet.dll 
+22
source

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

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

Even if your PHP file may be in the global namespace, but this is good practice.

+1
source

Source: https://habr.com/ru/post/927181/


All Articles