ubuntu 安装yar和使用
可能你的安裝 會出現(xiàn)一些依賴? 一般可能是? 缺少 m4 ? autoconf
鳥哥博客:http://www.laruence.com/2012/09/15/2779.html
安裝yar 先安裝msgpack
https://github.com/msgpack/msgpack-php
?whichis phpize
比如我的在:/usr/local/php/bin/phpize
一般php-config也在這里
我的msgpack 位置在 /home/jshawcx/msgpack-php-master
安裝yar
https://github.com/laruence/yar
我的yar位置在 /home/jshawcx/yar-1.2.4
?cd /xxxx/xxx/msgpack-php-master
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd /xxx/xxx/yar-1.2.4
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
extension=msgpack.so
extension=yar.so
重啟php-fpm 和nginx或apache
使用 :
http://php.net/manual/zh/book.yar.php
假如我的ip是 192.168.1.104,我的服務(wù)器配置 php文件在 /var/www/yaf
我的server php 就放在 這里比如是api.php, 我的項目入口 index.php 也在這里
<?php class API{ public function add($a,$b){ return $this->_add($a,$b); } public function sub($a, $b) { return $a - $b; } public function mul($a, $b) { return $a * $b; } protected function _add($a,$b){ return $a+$b; } } $server = new Yar_server(new API()); $server->handle(); ?>我的client index.php
$client = new yar_client("http://192.168.1.104/api.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));function callback($res,$callinfo){if?($callinfo?==?NULL)?{????????echo?"現(xiàn)在,?所有的請求都發(fā)出去了,?還沒有任何請求返回\n";
?????}?else?{
??????????????echo?"這是一個遠(yuǎn)程調(diào)用的返回,?調(diào)用的服務(wù)名是",?$callinfo["method"],?
??????????????????????".?調(diào)用的sequence是?"?,?$callinfo["sequence"]?,?"\n";
????????var_dump($retval);
?????} } Yar_concurrent_client::call("http://192.168.1.104/api.php","add",array(1,2),"callback"); Yar_concurrent_client::call("http://192.168.1.104/api.php","sub",array(2,1),"callback"); Yar_concurrent_client::call("http://192.168.1.104/api.php",'mul',array(2,2),'callback');
Yar_concurrent_client::loop();
?
轉(zhuǎn)載于:https://www.cnblogs.com/Sven-w/p/4278145.html
總結(jié)
以上是生活随笔為你收集整理的ubuntu 安装yar和使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 修改TOMCAT服务器图标为应用LOGO
- 下一篇: 在ubuntu 12.04 x64下编译