PHP 7.2.2 and Unicom

I am currently looking into writing a PHP interface that schedules Unicom tasks and i thought i would make a few post’s as i go along. Obviously, the first thing you have to do is to install PHP and set it up for COM use. Setting PHP up for COM is easy , just make sure you have this in your PHP.ini file. ( Search for [COM] )

; allow Distributed-COM calls
; http://php.net/com.allow-dcom
extension=php_com_dotnet.dll
com.allow_dcom = true

The way to check that com is enabled it so run a PHP file that has this in it

<?php
phpinfo(); 
?>

And when you run the file , make sure you see this

next we need to see if com is activated and works so i tried this on Excel. I have excel 2013 my machine

<?php 
     ini_set('display_errors', 1);
     ini_set('display_startup_errors', 1);
     error_reporting(E_ALL); 
     $xl = new COM("Excel.Application"); 
?>

and it produced this ,

Fatal error: Uncaught com_exception: 
Failed to create COM object `Excel.Application': 
Access is denied. in C:\inetpub\wwwroot\LoopMDD.php:9 Stack trace: #0 C:\inetpub\wwwroot\LoopMDD.php(9): 
com->com('Excel.Applicati...') #1 {main} thrown in C:\inetpub\wwwroot\LoopMDD.php on line 9

and i am ok with that as it shows the COM statement worked. If you want to take the excel thing further then you can take a look at this post and it will show you how to get access to XL this way. So whats next .. Well one of the first things i need to do is open an MDD so here is the PHP code to do that


<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

	echo 'Start';
  	$oMDM = new COM("MDM.Document") or die("Unable to instantiate MDM.Document"); 
	$oMDM->Open("C:\\inetpub\\wwwroot\\USERS.mdd", '', 2);
	foreach ($oMDM->Variables as $oVar) {
		echo $oVar->Label ."<br/>";
	}
	echo 'Done';

?>

and so when i ran the PHP file i got the labels. So PHP COM , 64bit is enabled and working , now onto the next bit, watch this space.