neofusion / json-rpc-bundle
此包已被废弃,不再维护。未建议替代包。
用于 Symfony 的 JSON-RPC 2.0 服务器
v0.3.0
2019-05-08 11:00 UTC
Requires
- php: ^5.5.9|^7.0
- symfony/framework-bundle: ^2.7|^3.0|^4.0
Requires (Dev)
- symfony/asset: ^2.7|^3.0|^4.0
- symfony/browser-kit: ^2.7|^3.0|^4.0
- symfony/phpunit-bridge: ^3.2|^4.0
- symfony/templating: ^2.7|^3.0|^4.0
- symfony/translation: ^2.7|^3.0|^4.0
- symfony/yaml: ^2.7|^3.0|^4.0
This package is not auto-updated.
Last update: 2022-04-30 06:39:46 UTC
README
用于 Symfony 的 JSON-RPC 2.0 服务器
安装
第1步:下载包
打开命令行,进入项目目录并执行以下命令以下载此包的最新稳定版本
$ composer require neofusion/json-rpc-bundle
此命令需要您全局安装了 Composer,如 Composer 文档中的安装章节所述。
第2步:启用包
然后,通过将其添加到项目 app/AppKernel.php
文件中注册的包列表中来启用此包
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new NeoFusion\JsonRpcBundle\NeoFusionJsonRpcBundle(), ); // ... } // ... }
第3步:配置 API 方法
您可以在配置文件中轻松定义方法
neofusion_jsonrpc: routing: customer: path: /customer methods: comment.create: { service: 'app.api.customer.comment', action: 'create' } comment.delete: { service: 'app.api.customer.comment', action: 'delete' }
routing
- 路由列表customer
- 路由的内部名称path
- 前缀之后的 URL 的第二部分methods
- 方法列表comment.create
- 方法名称service
- 包含可调用方法的服务的名称action
- 从服务中调用的可调用方法
第4步:注册路由
最后,通过将以下内容添加到项目的路由文件中,注册此包的路由
# app/config/routing.yml neofusion_jsonrpc: resource: "@NeoFusionJsonRpcBundle/Resources/config/routing.yml" prefix: /api