waylandace/json-rpc-bundle

Symfony的JSON-RPC 2.0服务器

安装: 608

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 2

开放问题: 1

类型:symfony-bundle

v3.1.2 2018-12-26 09:29 UTC

This package is auto-updated.

Last update: 2024-09-07 07:09:09 UTC


README

Symfony的JSON-RPC 2.0服务器

安装

步骤1:下载Bundle

打开命令控制台,进入项目目录,并执行以下命令以下载此bundle的最新稳定版本

$ composer require waylandace/json-rpc-bundle

此命令要求您全局安装Composer,如Composer文档中的安装章节所述。

步骤2:启用Bundle

然后,通过将其添加到项目中app/AppKernel.php文件的注册bundle列表中启用该bundle

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new NeoFusion\JsonRpcBundle\NeoFusionJsonRpcBundle(),
        );

        // ...
    }

    // ...
}

步骤3:配置API方法

您可以在配置文件(config/services.yaml)中轻松定义方法

services:
    App\Api\Auth:
        public: false
        tags:
          - { name: 'app.api.json_rpc', alias: 'auth' }
    

步骤4:注册路由

最后,通过将以下内容添加到项目的路由文件中注册此bundle的路由

# app/config/routes/neofusion_jsonrpc.yaml
neofusion_jsonrpc:
    resource: "@NeoFusionJsonRpcBundle/Controller/ServerController.php"
    prefix: /
    type: annotation

步骤5:注册编译器

# src/Kernel.php
    protected function build(ContainerBuilder $container)
    {
        $container->addCompilerPass(new JsonRpcPass());
    }