unify/connector

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

微中台服务中心-连接器

v0.9 2020-10-14 09:24 UTC

This package is auto-updated.

Last update: 2021-11-14 11:53:53 UTC


README

发布

php bin/hyperf.php vendor:publish unify/connector

该扩展依赖文件系统,需要同时发布文件系统配置
php bin/hyperf.php vendor:publish hyperf/filesystem

对于发布失败的文件,可以通过手动修改
或者命令强制覆盖:

/bin/cp -f vendor/unify/connector/publish/AbstractController.php app/Controller/AbstractController.php
/bin/cp -f vendor/unify/connector/publish/ErrorCode.php app/Constants/ErrorCode.php
/bin/cp -f vendor/unify/connector/publish/Model.php app/Model/Model.php 

配置

  • 配置文件

    • 配置unify.php中的应用ID,密钥
    • 配置services.php中的服务地址

    .env

    UNIFY_RPC_APP_ID=888
    UNIFY_RPC_APP_KEY=73ce3e2f15ff247e0f362e4417a202012
    UNIFY_RPC_NODES=127.0.0.1:9518
    
  • 配置AOP

    无需特殊配置

  • 配置异常处理

    需要手动在config/autoload/exceptions.php注册

    return [
        'handler' => [
            'http' => [
                // ...其他异常handler
                App\Exception\Handler\RecvExceptionHandler::class,
                App\Exception\Handler\RequestExceptionHandler::class,
                // ...其他异常handler
                App\Exception\Handler\AppExceptionHandler::class,
            ],
        ],
    ];

路由管理

  • 输出路由到控制台(不上报)
php bin/hyperf.php route:report -o true
  • 输出路由到文件(不上报)
php bin/hyperf.php route:report -f true

# 需要文件驱动
composer require hyperf/filesystem
php bin/hyperf.php vendor:publish hyperf/filesystem
  • 路由上报
php bin/hyperf.php route:report