Update manual

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@332233 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Xinchen Hui 2013-12-02 04:33:49 +00:00
parent c5c812a815
commit 416bc5284c
3 changed files with 121 additions and 26 deletions

View file

@ -4,23 +4,118 @@
<chapter xml:id="yar.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<example>
<title>Yar Example</title>
<title>Yar Server Example</title>
<programlisting role="php">
<![CDATA[
<?php
/* ... */
/* assume this page can be accessed by http://example.com/operator.php */
class Operator {
/**
* Add two operands
* @param interge
* @return interge
*/
public function add($a, $b) {
return $this->_add($a, $b);
}
/**
* Sub
*/
public function sub($a, $b) {
return $a - $b;
}
/**
* Mul
*/
public function mul($a, $b) {
return $a * $b;
}
/**
* Protected methods will not be exposed
* @param interge
* @return interge
*/
protected function _add($a, $b) {
return $a + $b;
}
}
?>
]]>
</programlisting>
</example>
<example>
<title>Access the server in borwser(GET request)</title>
&example.outputs.similar;
<mediaobject>
<alt>Yar Server Info</alt>
<imageobject>
<imagedata fileref="en/reference/yar/image/yar.png"/>
</imageobject>
</mediaobject>
</example>
<example>
<title>Yar Client Example</title>
<programlisting role="php">
<![CDATA[
<?php
$client = yar_client("http://example.com/operator.php");
/* call directly */
var_dump($client->add(1, 2));
/* call via call */
var_dump($client->call("add", array(3, 2)));
/* __add can not be called */
var_dump($client->_add(1, 2));
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
int(3)
int(5)
PHP Fatal error: Uncaught exception 'Yar_Server_Exception' with message 'call to api Operator::_add() failed' in *
]]>
</screen>
</example>
<example>
<title>Yar Concurrent Client Example</title>
<programlisting role="php">
<![CDATA[
<?php
function callback($ret, $callinfo) {
echo $callinfo['method'] , " result: ", $ret , "\n";
}
Yar_Concurrent_Client::call("http://example.com/operator.php", "add", array(1, 2), "callback");
Yar_Concurrent_Client::call("http://example.com/operator.php", "sub", array(2, 1), "callback");
Yar_Concurrent_Client::call("http://example.com/operator.php", "mul", array(2, 2), "callback");
Yar_Concurrent_Client::loop();
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
...
mul result: 4
sub result: 1
add result: 3
]]>
</screen>
</screen>
</example>
</chapter>
<!-- Keep this comment at the end of the file

BIN
reference/yar/image/yar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View file

@ -23,12 +23,6 @@
<entry>PHP_INI_SYSTEM</entry>
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
</row>
<row>
<entry><link linkend="ini.yar.transport">yar.transport</link></entry>
<entry>curl</entry>
<entry>PHP_INI_SYSTEM</entry>
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
</row>
<row>
<entry><link linkend="ini.yar.debug">yar.debug</link></entry>
<entry>Off</entry>
@ -37,16 +31,22 @@
</row>
<row>
<entry><link linkend="ini.yar.connect-timeout">yar.connect_timeout</link></entry>
<entry>1</entry>
<entry>1000</entry>
<entry>PHP_INI_ALL</entry>
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
</row>
<row>
<entry><link linkend="ini.yar.timeout">yar.timeout</link></entry>
<entry>5</entry>
<entry>5000</entry>
<entry>PHP_INI_ALL</entry>
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
</row>
<row>
<entry><link linkend="ini.yar.expose-info">yar.expose_info</link></entry>
<entry>On</entry>
<entry>PHP_INI_SYS</entry>
<entry><!-- leave empty, this will be filled by an automatic script --></entry>
</row>
</tbody>
</tgroup>
</table>
@ -63,18 +63,7 @@
</term>
<listitem>
<para>
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.yar.transport">
<term>
<parameter>yar.transport</parameter>
<type>string</type>
</term>
<listitem>
<para>
it could be php, json, and msgpack(require built with msgpack support)
</para>
</listitem>
</varlistentry>
@ -96,7 +85,7 @@
</term>
<listitem>
<para>
timeout in ms
</para>
</listitem>
</varlistentry>
@ -107,7 +96,18 @@
</term>
<listitem>
<para>
timeout in ms
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.yar.expose-info">
<term>
<parameter>yar.timeout</parameter>
<type>bool</type>
</term>
<listitem>
<para>
whether expose the service info(when access the server via GET)
</para>
</listitem>
</varlistentry>