Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 1857

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>PHP and COM</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="faq.html.html">PHP and HTML</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="faq.languages.html">PHP and other languages</a></div>
 <div class="up"><a href="faq.html">FAQ</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="faq.com" class="chapter">
  <h1>PHP and COM</h1>

  

   <p class="para">
    PHP can be used to access COM and DCOM objects on Win32 platforms.
   </p>

  <div class="qandaset"><ol class="qandaset_questions"><li><a href="#faq.com.q1">
     
      I have built a DLL to calculate something. Is there any way to run this DLL under PHP ?
     
    </a></li><li><a href="#faq.com.q2">
     
      What does &#039;Unsupported variant type: xxxx (0xxxxx)&#039; mean ?
     
    </a></li><li><a href="#faq.com.q3">
     
      Is it possible manipulate visual objects in PHP ?
     
    </a></li><li><a href="#faq.com.q4">
     
      Can I store a COM object in a session ?
     
    </a></li><li><a href="#faq.com.q5">
     
      How can I trap COM errors ?
     
    </a></li><li><a href="#faq.com.q6">
     
      Can I generate DLL files from PHP scripts like I can in Perl ?
     
    </a></li><li><a href="#faq.com.q7">
     
      What does &#039;Unable to obtain IDispatch interface for CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}&#039; mean ?
     
    </a></li><li><a href="#faq.com.q8">
     
      How can I run COM object from remote server ?
     
    </a></li><li><a href="#faq.com.q9">
     
      I get &#039;DCOM is disabled in C:\path...\scriptname.php on line 6&#039;, what can I do ?
     
    </a></li><li><a href="#faq.com.q10">
     
      Is it possible to load/manipulate an ActiveX object in a page with PHP ?
     
    </a></li><li><a href="#faq.com.q11">
     
      Is it possible to get a running instance of a component ?
     
    </a></li><li><a href="#faq.com.q12">
     
      Is there a way to handle an event sent from COM object ?
     
    </a></li><li><a href="#faq.com.q13">
     
      I&#039;m having problems when trying to invoke a method of a COM object 
      which exposes more than one interface. What can I do ?
     
    </a></li><li><a href="#faq.com.q14">
     
      So PHP works with COM, how about COM+ ?
     
    </a></li><li><a href="#faq.com.q15">
     
      If PHP can manipulate COM objects, can we imagine to use 
      MTS to manage components resources, in conjunction with PHP ?
     
    </a></li></ol></div>
   <dl class="qandaentry" id="faq.com.q1">
    <dt><strong>
     
      I have built a DLL to calculate something. Is there any way to run this DLL under PHP ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      If this is a simple DLL there is no way yet to run it from PHP. If the DLL contains a COM
      server you may be able to access it if it implements the IDispatch interface.
     </p>
    </dd>
   </dl>
   
   <dl class="qandaentry" id="faq.com.q2">
    <dt><strong>
     
      What does &#039;Unsupported variant type: xxxx (0xxxxx)&#039; mean ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      There are dozens of VARIANT types and combinations of them. Most of them are already supported but
      a few still have to be implemented.
      Arrays are not completely supported. Only single dimensional indexed
      only arrays can be passed between PHP and COM.
      If you find other types that aren&#039;t supported, please report them as a bug (if not already reported)
      and provide as much information as available.
     </p>
    </dd>
   </dl>
  
   <dl class="qandaentry" id="faq.com.q3">
    <dt><strong>
     
      Is it possible manipulate visual objects in PHP ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      Generally it is, but as PHP is mostly used as a web scripting language it runs in the web servers context, thus
      visual objects will never appear on the servers desktop.
      If you use PHP for application scripting e.g. in conjunction with PHP-GTK there is no limitation in accessing and
      manipulating visual objects through COM.
     </p>
    </dd>
   </dl>
  
   <dl class="qandaentry" id="faq.com.q4">
    <dt><strong>
     
      Can I store a COM object in a session ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      No, you can&#039;t. COM instances are treated as resources and therefore they are only available in a single script&#039;s context.
     </p>
    </dd>
   </dl>
  
   <dl class="qandaentry" id="faq.com.q5">
    <dt><strong>
     
      How can I trap COM errors ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      In PHP 5, the COM extension throws <em>com_exception</em>
      exceptions, which you can catch and then inspect the <em>code</em>
      member to determine what to do next.
     </p>
     <p class="para">
      In PHP 4 it&#039;s not possible to trap COM errors beside the ways provided by PHP itself (@, track_errors, ..).
     </p>
    </dd>
   </dl>
  
   <dl class="qandaentry" id="faq.com.q6">
    <dt><strong>
     
      Can I generate DLL files from PHP scripts like I can in Perl ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      No, unfortunately there is no such tool available for PHP.
     </p>
    </dd>
   </dl>
  
   <dl class="qandaentry" id="faq.com.q7">
    <dt><strong>
     
      What does &#039;Unable to obtain IDispatch interface for CLSID {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}&#039; mean ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      This error can have multiple reasons:
      <ul class="itemizedlist">
       <li class="listitem">
         <span class="simpara">
         the CLSID is wrong
         </span>
        </li>
       <li class="listitem">
         <span class="simpara">
         the requested DLL is missing
         </span>
        </li>
       <li class="listitem">
         <span class="simpara">
         the requested component doesn&#039;t implement the IDispatch interface
         </span>
        </li>
       </ul>
     </p>
    </dd>
   </dl>
    
   <dl class="qandaentry" id="faq.com.q8">
    <dt><strong>
     
      How can I run COM object from remote server ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      Exactly like you run local objects. You only have to pass the IP of the remote machine as second parameter to
      the COM constructor.
     </p>
     <p class="para">
      Make sure that you have set
      <a href="com.configuration.html#ini.com.allow-dcom" class="link">com.allow_dcom</a><em>=</em><strong><code>TRUE</code></strong>
      in your <var class="filename">php.ini</var>.
     </p>
    </dd>
   </dl>
   
   <dl class="qandaentry" id="faq.com.q9">
    <dt><strong>
     
      I get &#039;DCOM is disabled in C:\path...\scriptname.php on line 6&#039;, what can I do ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      Edit your <var class="filename">php.ini</var> and set
      <a href="com.configuration.html#ini.com.allow-dcom" class="link">com.allow_dcom</a><em>=</em><strong><code>TRUE</code></strong>.
     </p>
    </dd>
   </dl>
   
   <dl class="qandaentry" id="faq.com.q10">
    <dt><strong>
     
      Is it possible to load/manipulate an ActiveX object in a page with PHP ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      This has nothing to do with PHP. ActiveX objects are loaded on client side if they are requested
      by the HTML document. There is no relation to the PHP script and therefore there is no direct
      server side interaction possible.
     </p>
    </dd>
   </dl>
   <dl class="qandaentry" id="faq.com.q11">
    <dt><strong>
     
      Is it possible to get a running instance of a component ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      This is possible with the help of monikers. If you want to get multiple references to the same word instance
      you can create that instance like shown:
     </p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$word&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">COM</span><span style="color: #007700">(</span><span style="color: #DD0000">"C:\docs\word.doc"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

     <p class="para">
      This will create a new instance if there is no running instance available or it will return a handle to the
      running instance, if available.
     </p>
    </dd>
   </dl>
   <dl class="qandaentry" id="faq.com.q12">
    <dt><strong>
     
      Is there a way to handle an event sent from COM object ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      You can define an event sink and bind it using
       <span class="function"><a href="function.com-event-sink.html" class="function">com_event_sink()</a></span>.  You can use
       <span class="function"><a href="function.com-print-typeinfo.html" class="function">com_print_typeinfo()</a></span> to have PHP generate a skeleton
      for the event sink class.
     </p>
    </dd>
   </dl>
   
   <dl class="qandaentry" id="faq.com.q13">
    <dt><strong>
     
      I&#039;m having problems when trying to invoke a method of a COM object 
      which exposes more than one interface. What can I do ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      The answer is as simple as unsatisfying. I don&#039;t know exactly but i think you can do nothing.
      If someone has specific information about this, please let <a href="mailto:harald.radi@nme.at" class="link external">&raquo;&nbsp;me</a> know :)
     </p>
    </dd>
   </dl>
   
   <dl class="qandaentry" id="faq.com.q14">
    <dt><strong>
     
      So PHP works with COM, how about COM+ ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      COM+ extends COM by a framework for managing components through MTS and MSMQ but there is nothing special that
      PHP has to support to use such components.
     </p>
    </dd>
   </dl>
   
   <dl class="qandaentry" id="faq.com.q15">
    <dt><strong>
     
      If PHP can manipulate COM objects, can we imagine to use 
      MTS to manage components resources, in conjunction with PHP ?
     
    </strong></dt>
    <dd class="answer">
     <p class="para">
      PHP itself doesn&#039;t handle transactions yet. Thus if an error 
      occurs no rollback is initiated. If you use components that
      support transactions you will have to implement the 
      transaction management yourself.
     </p>
    </dd>
   </dl>
 
  
 </div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="faq.html.html">PHP and HTML</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="faq.languages.html">PHP and other languages</a></div>
 <div class="up"><a href="faq.html">FAQ</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>