<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.yar-server.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'yar-server.construct.php',
    1 => 'Yar_Server::__construct',
    2 => 'Create an RPC server',
  ),
  'up' => 
  array (
    0 => 'class.yar-server.php',
    1 => 'Yar_Server',
  ),
  'prev' => 
  array (
    0 => 'class.yar-server.php',
    1 => 'Yar_Server',
  ),
  'next' => 
  array (
    0 => 'yar-server.handle.php',
    1 => 'Yar_Server::handle',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yar/yar_server/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yar-server.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yar_Server::__construct</h1>
  <p class="verinfo">(PECL yar &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Yar_Server::__construct</span> &mdash; <span class="dc-title">Create an RPC server</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yar-server.construct-description">
  <h3 class="title">Опис</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="modifier">function</span> <span class="methodname"><strong>Yar_Server::__construct</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.object.php" class="type object">object</a></span> <code class="parameter">$executor</code></span>)</div>

  <p class="simpara">
   Creates a Yar HTTP RPC server. All public methods of
   <code class="parameter">executor</code> are registered as RPC services.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yar-server.construct-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">executor</code></dt>
    <dd>
     <p class="simpara">
      Any object whose public methods should be exposed as RPC
      services. Protected and private methods, and methods whose name
      starts with an underscore, are not exposed.
     </p>
     <p class="simpara">
      The executor can optionally define two protected magic methods,
      which are recognized by
      <span class="methodname"><a href="yar-server.handle.php" class="methodname">Yar_Server::handle()</a></span> and never exposed as
      RPC endpoints:
     </p>
     <ul class="itemizedlist">
      <li class="listitem">
       <p class="simpara">
        <code class="literal">protected function __info(string $markup):
        string</code> — as of Yar 2.3.0. Called when the service
        information page is requested; it receives the markup of the
        page Yar would otherwise render, and if it returns a <span class="type"><a href="language.types.string.php" class="type string">string</a></span>,
        that string is sent to the client instead. See
        <span class="methodname"><a href="yar-server.handle.php" class="methodname">Yar_Server::handle()</a></span>.
       </p>
      </li>
      <li class="listitem">
       <p class="simpara">
        <code class="literal">protected function __auth(string $provider, string
        $token): bool</code> — as of Yar 2.3.0. Called at the very
        beginning of every request with the
        <code class="literal">provider</code> and <code class="literal">token</code>
        fields of the request header, set by the client with the
        <strong><code><a href="yar.constants.php#constant.yar-opt-provider">YAR_OPT_PROVIDER</a></code></strong> and
        <strong><code><a href="yar.constants.php#constant.yar-opt-token">YAR_OPT_TOKEN</a></code></strong> options. Returning exactly
        <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> rejects the request; any other return value lets it
        proceed. See <span class="methodname"><a href="yar-server.handle.php" class="methodname">Yar_Server::handle()</a></span>.
       </p>
      </li>
     </ul>
     <p class="simpara">
      Both methods only take effect when they are
      <code class="literal">protected</code>; a public or private method with
      the same name is ignored.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-yar-server.construct-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="simpara">
   An instance of <span class="classname"><a href="class.yar-server.php" class="classname">Yar_Server</a></span>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yar-server.construct-examples">
  <h3 class="title">Приклади</h3>
  <div class="example" id="example-1">
   <p><strong>Приклад #1 <span class="methodname"><strong>Yar_Server::__construct()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
</span><span style="color: #007700">class </span><span style="color: #0000BB">API </span><span style="color: #007700">{
    </span><span style="color: #FF8000">/**
     * The doc block is shown on the service info page.
     * @param string $parameter
     * @return string
     */
    </span><span style="color: #007700">public function </span><span style="color: #0000BB">some_method</span><span style="color: #007700">(</span><span style="color: #0000BB">$parameter</span><span style="color: #007700">, </span><span style="color: #0000BB">$option </span><span style="color: #007700">= </span><span style="color: #DD0000">"foo"</span><span style="color: #007700">) {
         return </span><span style="color: #DD0000">"some_method"</span><span style="color: #007700">;
    }

    protected function </span><span style="color: #0000BB">client_can_not_see</span><span style="color: #007700">() {
    }
}

</span><span style="color: #0000BB">$service </span><span style="color: #007700">= new </span><span style="color: #0000BB">Yar_Server</span><span style="color: #007700">(new </span><span style="color: #0000BB">API</span><span style="color: #007700">());
</span><span style="color: #0000BB">$service</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">handle</span><span style="color: #007700">();
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yar-server.construct-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="yar-server.handle.php" class="methodname" rel="rdfs-seeAlso">Yar_Server::handle()</a> - Start the RPC server</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>