php 安装yar扩展

注意:如需调用,客户端和服务端均需安装yar及msg

https://blog.csdn.net/diandianxiyu_geek/article/details/17119341
http://note.youdao.com/noteshare?id=2e320b72cc5f348bd916ffd9f159da83&sub=20EE565CDF3546CC815D5F321A1819F0

可能碰到的问题:测试阶段局域网跨域解析注意ping一下域名,看看能不能ping通,
一定要注意域名解析的问题
注意路由器配置解析的时候域名先后的问题,特殊域名靠前,泛域名靠后

1.安装及使用参照文档<>yar的安装和使用>  注:注意use命名空间

客户端调用:

    public function __construct()
    {
        parent::__construct();
        $url = 'http://zn.zhinong.com/index.php/index/themebar';
        $this->obj =  new \Yar_client($url);
        $this->obj->SetOpt(YAR_OPT_CONNECT_TIMEOUT, 1000);
    }
    public function t1()
    {

        $res= $this->obj->test('i am test');
        echo $res;
    }
服务端创建:

<?php

namespace appindexcontroller;

use thinkController;
use thinkcontrollerYar;
use thinkRequest;

class Themebar extends Yar
{
    /**
     * 显示资源列表
     *
     * @return thinkResponse
     */
    public function index()
    {

        //
    }

    public function test($a = 'it is test api')
    {
        echo $a;

    }
}


2.本框架采用tp5.0搭建,controller模块负责提供接口数据和逻辑处理,model模块负责数据库交互,每一个表对应一个model
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容