承接 mustafa3264/cor-yar 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mustafa3264/cor-yar

最新稳定版本:v1.0.8

Composer 安装命令:

composer require mustafa3264/cor-yar

包简介

yar server for hyperf

README 文档

README

基于 bromine-mai/cor-yar 实现的 hyperf 框架可用的 yar 服务端/客户端工具

composer require mustafa3264/cor-yar

使用教程

config/autoload/server.php

替换 callbacks Event::ON_REQUEST 为 \Mustafa\CorYar\YarServer::class

    'servers' => [
        [
            'name' => 'http',
            'type' => Server::SERVER_HTTP,
            'host' => '0.0.0.0',
            'port' => 9501,
            'sock_type' => SWOOLE_SOCK_TCP,
            'callbacks' => [
                Event::ON_REQUEST => [\Mustafa\CorYar\YarServer::class, 'onRequest'],
            ],
        ],
    ],

服务端使用

加在类方法中 model为代理yar请求实现的model

use Mustafa\CorYar\Annotation\YarServer;

#[YarServer(model: \App\Model\Services\Interfaces\CalculatorServiceInterface::class)]
public function t3()
{
}

客户端使用

加在类属性中,属性url为 yar服务端地址

use Mustafa\CorYar\Annotation\YarClient;

#[YarClient(url: 'http://127.0.0.1:9501/calculate/t3')]
public $test_client;

示例

<?php

declare(strict_types=1);

namespace App\Controller;

use Hyperf\HttpServer\Annotation\AutoController;
use Mustafa\CorYar\Annotation\YarClient;
use Mustafa\CorYar\Annotation\YarServer;

class CalculateController extends AbstractController
{

    #[YarClient(url: 'http://127.0.0.1:9501/calculate/t3')]
    public $test_client;

    public function t1()
    {
        return $this->test_client->add(25, 20);
    }

    #[YarServer(model: \App\Model\Services\Interfaces\CalculatorServiceInterface::class)]
    public function t3()
    {
    }
}
    Router::addGroup('/calculate', static function () {
        Router::post('/myyarserver', 'App\Controller\CalculateController@myyarserver');
        Router::get('/myyarclient', 'App\Controller\CalculateController@myyarclient');
    });

联系作者

我的邮箱

微信

fanghailiang2023

统计信息

  • 总下载量: 43
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固