yar扩展下载地址 http://php.net/manual/zh/book.yar.php
、根据php版本号,选择下载对应的yar安装包
下载解压拿到php_yar.dll。放到ext目录下,在php.ini里面加入extension=php_yar.dll 重启php(注意:wampserver中增加扩展,直接修改运行中wampserver中的php.ini,在bin目录下直接增加扩展不生效)
在tp框架中简单的使用
服务器端
class Yar extends BaseController
{
public function __construct()
{
if (!extension_loaded('yar')) {
throw new \Exception('缺少yar扩展');
}
$server = new \Yar_Server($this);
$server->handle();
}
public function __call($name, $arguments)
{
return 'Method does not exist';
}
}
class Index extends Yar
{
public function register($request =[])
{
return '注册成功';
}
}
客户端
$client = new yar_client("http://127.0.0.1//index.php/user/index");
var_dump($client->register([]));
// 调用报错一般为服务器端错误,使用路由访问解决错误