Example #1
3
 public function getConfigAction()
 {
     $requestVO = Services_Widget_SetVO::instance()->setRequestGetConfigVO($this->params);
     if (Services_Widget_SetVO::instance()->checkIfRPC($requestVO)) {
         $service1 = new Yar_Server(new Services_Widget_Transaction());
         $service1->handle();
     } else {
         var_dump(__CLASS__, __FUNCTION__);
     }
 }
Example #2
0
 /**
  * 架构函数
  * @access public
  */
 public function initialize()
 {
     if (!extension_loaded('yar')) {
         die('Not Yar');
     }
     $server = new \Yar_Server($this);
     $server->handle();
 }
Example #3
0
 public function handle()
 {
     try {
         $service = $this->service(empty($_GET['service']) ? 'NotFoundService' : $_GET['service']);
     } catch (\Exception $e) {
         $service = $this->service('NotFoundService');
     }
     $server = new \Yar_Server($service);
     return $server->handle();
 }
Example #4
0
 /**
  * 架构函数
  * @access public
  */
 public function __construct()
 {
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
     //判断扩展是否存在
     if (!extension_loaded('yar')) {
         throw new \Exception('not support yar');
     }
     //实例化Yar_Server
     $server = new \Yar_Server($this);
     // 启动server
     $server->handle();
 }
Example #5
0
 /**
  * 架构函数
  * @access public
  */
 public function __construct()
 {
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
     //判断扩展是否存在
     if (!extension_loaded('yar')) {
         E(L('_NOT_SUPPORT_') . ':yar');
     }
     //实例化Yar_Server
     $server = new \Yar_Server($this);
     // 启动server
     $server->handle();
 }
Example #6
0
<?php

$start = microtime(true);
ini_set('display_errors', 1);
error_reporting(E_ALL);
define("APP_PATH", realpath(dirname(__FILE__) . '/../app/'));
/* 指向public的上一级 */
require '../vendor/autoload.php';
if (isset($_SERVER['HTTP_USER_AGENT']) && substr($_SERVER['HTTP_USER_AGENT'], 0, 11) === 'PHP Yar Rpc') {
    require APP_PATH . '/application/Service.php';
    $service = new Yar_Server(new Service());
    $service->handle();
} else {
    $app = new Yaf_Application(APP_PATH . "/conf/application.ini");
    $params = array();
    if (Yaf_Dispatcher::getInstance()->getRequest()->isGet()) {
        $params = Yaf_Dispatcher::getInstance()->getRequest()->getQuery();
    } else {
        $params = Yaf_Dispatcher::getInstance()->getRequest()->getPost();
    }
    foreach ($params as $key => $value) {
        Yaf_Dispatcher::getInstance()->getRequest()->setParam($key, $value);
    }
    $app->bootstrap()->run();
}
$end = microtime(true);
$time = ($end - $start) * 1000;
// echo "\n<br>".$time.'ms';
// echo number_format($time, 10, '.', ");
Example #7
0
 public function userAction()
 {
     $apiServer = new Yar_Server(new api\User());
     $apiServer->handle();
     return false;
 }
Example #8
0
 public function run()
 {
     $rpc = new \Yar_Server(new self());
     $rpc->handle();
 }
Example #9
0
<?php

/**
 * @date 2015-9-13 
 * @author zhengyin <*****@*****.**>
 * @blog http://izhengyin.com
 *
 */
class Server
{
    public function get()
    {
        return __METHOD__;
    }
    public function add()
    {
        return __METHOD__;
    }
    public function update()
    {
        return __METHOD__;
    }
    public function delete()
    {
        return __METHOD__;
    }
}
$server = new Yar_Server(new Server());
$server->handle();
Example #10
0
 public function indexAction()
 {
     $server = new Yar_Server(new RedisCluster());
     $server->handle();
     die;
 }
Example #11
0
 public function yarAction()
 {
     $server = new Yar_Server(new TestModel());
     $server->handle();
     return false;
 }
Example #12
0
 public function handle($object)
 {
     if (!is_object($object)) {
         if (class_exists($object)) {
             $object = new $object();
         }
         throw new Exception("[error] the {$object} is not a object!");
     }
     $yar = new \Yar_Server($object);
     $yar->handle();
 }
Example #13
0
<?php

error_reporting(-1);
class Service_Provider
{
    public function __auth($provider, $token)
    {
        if (!$provider || $provider !== $token) {
            return false;
        } else {
            return true;
        }
    }
    public function normal($uid, $version = "3.6")
    {
        return $version;
    }
}
$yar = new Yar_Server(new Service_Provider());
$yar->handle();
Example #14
0
 public function userAction()
 {
     Yaf_Loader::import(LIB_PATH . '/yar/Yar_User.php');
     $service = new Yar_Server(new Yar_User());
     $service->handle();
 }