Yar轻量级、可串行也可并行、可通过get方法查看接口列表和注释,只需要把接口信息整理好,就能在查看接口的时候同时查看接口文档了。
轻量级、并行php RPC框架,只支持php程序之间的相互调用。
优点:轻量级、可串行也可并行、可通过get方法查看接口列表和注释,只需要把接口信息整理好,就能在查看接口的时候同时查看接口文档了。
缺点:不支持跨语言调用。
git clone https://github.com/laruence/yar.git
phpize
./configure
make & make install
// 安装成功后,在php.ini中添加extension=yar.so,重启fpm即可
./configure报错
configure: error: Please reinstall the libcurl distribution - easy.h in <curl-dir>/include/curl/
需要安装apt-get install libcurl4-gnutls-dev
yar支持php、json和Msgpack三种打包工具,默认是php,如果要用Msgpack的话要先安装Msgpack扩展,然后配置时加上--enable-msgpack参数。但实际使用中发现,php的serialize和msgpack的效率几乎差不太多,甚至serialize性能还要好一点点,不过serialize所占的空间要稍大一些,个人认为没有必要用msgpack。
<?php
// this is a yar server
Class Api{
/**
* this is a comments
* api documents writes here
*/
function add($a,$b){
return $a+$b;
}
function mult($a,$b){
return $a*$b;
}
protected function _add(){
return 'this can\'t be seen by client';
}
}
$server = new Yar_Server(new Api(
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- pqdy.cn 版权所有 赣ICP备2024042791号-6
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务