Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 8742

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>Introduction</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="book.sca.html">SCA</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sca.setup.html">Installing/Configuring</a></div>
 <div class="up"><a href="book.sca.html">SCA</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="intro.sca" class="preface">
  <h1 class="title">Introduction</h1>
  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">This extension is
<em class="emphasis">EXPERIMENTAL</em>. The behaviour of this extension including
the names of its functions and any other documentation surrounding this
extension may change without notice in a future release of PHP.
This extension should be used at your own risk.</p></div>
  <p class="para"> 
   SCA for PHP makes it possible for a PHP programmer to write
   reusable components, which can be called in a variety of ways, with an
   identical interface and with a minimum of fuss. At present
   components can call each other either locally or via Web services,
   but in the future it is expected that other ways will be possible. It
   provides the programmer with a way of doing this which will look as
   natural as possible in PHP. 
  </p>
  
  <p class="para"> 
   SCA components use phpDocumentor-style (see
   http://www.phpdoc.org/) annotations to declare dependencies on
   other SCA components or Web services. The SCA for PHP runtime
   resolves these dependencies at runtime on behalf of the components,
   and thus allows the PHP programmer to focus on the business logic
   rather than on locating and obtaining references to dependencies.
  </p>
  
  <p class="para"> 
   The SCA for PHP programming model can be extended to support a
   number of service types, such as REST and Atompub. However, Web
   services (more accurately, WSDL defined, SOAP/HTTP services), are
   the only type currently specified. 
  </p>
  
  <p class="para"> 
   Components also use annotations to define the interface which
   they expose as a service. The SCA for PHP runtime will automatically
   generate WSDL from these annotations, so that an SCA component is
   easily exposed as a web service. These annotations are a natural
   extension to those provided by phpDocumentor. Deploying a Web
   service can be as simple as placing a PHP component under the document
   root of a web server. 
  </p>
  
  <p class="para"> 
   Components also use annotations to specify data structures
   (expressed using XML schema complex types) which are then handled
   using Service Data Objects (SDOs). 
  </p>
  
  <p class="para"> 
   A PHP script which is not an SCA component and which contains no
   annotations can use the services of an SCA component. A PHP script or
   component can make calls to a web service that is not an SCA component,
   but using the same system of calls or annotations to obtain a
   reference.
  </p>

  <p class="para"> 
   First we show a single SCA component, ConvertedStockQuote
   which illustrates many of the features of SCA for PHP. It has one
   method,
    <span class="function"><strong>getQuote()</strong></span>, which given a stock &quot;ticker&quot;
   obtains a price quote for that stock, converted to a given currency.
   We shall be using this example as a basis for explaining the SCA for PHP
   throughout the rest of this document. 
  </p>
  
  <p class="para">
   <div class="example" id="example-5295">
    <p><strong>Example #1  A sample SCA component </strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">"SCA/SCA.php"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Calculate&nbsp;a&nbsp;stock&nbsp;price&nbsp;for&nbsp;a&nbsp;given&nbsp;ticker&nbsp;symbol&nbsp;in&nbsp;a&nbsp;given&nbsp;currency.<br />&nbsp;*<br />&nbsp;*&nbsp;@service<br />&nbsp;*&nbsp;@binding.soap<br />&nbsp;*/<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">ConvertedStockQuote&nbsp;</span><span style="color: #007700">{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/**<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;The&nbsp;currency&nbsp;exchange&nbsp;rate&nbsp;service&nbsp;to&nbsp;use.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@reference<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@binding.php&nbsp;../ExchangeRate/ExchangeRate.php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">public&nbsp;</span><span style="color: #0000BB">$exchange_rate</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/**<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;The&nbsp;stock&nbsp;quote&nbsp;service&nbsp;to&nbsp;use.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@reference<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@binding.soap&nbsp;../StockQuote/StockQuote.wsdl<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">public&nbsp;</span><span style="color: #0000BB">$stock_quote</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/**<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Get&nbsp;a&nbsp;stock&nbsp;quote&nbsp;for&nbsp;a&nbsp;given&nbsp;ticker&nbsp;symbol&nbsp;in&nbsp;a&nbsp;given&nbsp;currency.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;string&nbsp;$ticker&nbsp;The&nbsp;ticker&nbsp;symbol.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;string&nbsp;$currency&nbsp;What&nbsp;currency&nbsp;to&nbsp;convert&nbsp;the&nbsp;value&nbsp;to.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;float&nbsp;The&nbsp;stock&nbsp;value&nbsp;is&nbsp;the&nbsp;target&nbsp;currency.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">getQuote</span><span style="color: #007700">(</span><span style="color: #0000BB">$ticker</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$currency</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$quote&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">stock_quote</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getQuote</span><span style="color: #007700">(</span><span style="color: #0000BB">$ticker</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$rate&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">exchange_rate</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRate</span><span style="color: #007700">(</span><span style="color: #0000BB">$currency</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;&nbsp;</span><span style="color: #0000BB">$rate&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">$quote</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  
  <p class="para"> 
   In this example, we see that an SCA component is implemented by a
   script containing a PHP class and includes
   <var class="filename">SCA.php</var>. The class contains a mixture of
   business logic and references to other components or services. In
   the illustrated
    <span class="function"><strong>getQuote()</strong></span> method there is only business
   logic, but it relies on the instance variables
   <var class="varname"><var class="varname">$stock_quote</var></var> and
   <var class="varname"><var class="varname">$exchange_rate</var></var> having been initialized.
   These refer to two other components and will be initialized by the SCA
   runtime with proxies for these two services, whenever this
   component executes. The annotations for these two services show one
   to be a local component, which will be called within the same PHP
   runtime, and one to be a remote component which will be called via a
   SOAP request. This component also exposes the
    <span class="function"><strong>getQuote()</strong></span> method both locally and as a web
   service, so it in turn can be called either locally or remotely.
  </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="book.sca.html">SCA</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sca.setup.html">Installing/Configuring</a></div>
 <div class="up"><a href="book.sca.html">SCA</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>