waylandace / json-rpc-bundle
JSON-RPC 2.0 Server for Symfony
Installs: 608
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.2
- ext-json: *
- symfony/framework-bundle: ^4.2
Requires (Dev)
- symfony/asset: ^4.2
- symfony/browser-kit: ^4.2
- symfony/phpunit-bridge: ^4.2
- symfony/templating: ^4.2
- symfony/translation: ^4.2
- symfony/yaml: ^4.2
This package is auto-updated.
Last update: 2024-11-07 07:29:21 UTC
README
JSON-RPC 2.0 Server for Symfony
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require waylandace/json-rpc-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new NeoFusion\JsonRpcBundle\NeoFusionJsonRpcBundle(), ); // ... } // ... }
Step 3: Configure API methods
You can easily define methods in your configuration file (config/services.yaml):
services: App\Api\Auth: public: false tags: - { name: 'app.api.json_rpc', alias: 'auth' }
Step 4: Register the routes
Finally, register this bundle's routes by adding the following to your project's routing file:
# app/config/routes/neofusion_jsonrpc.yaml neofusion_jsonrpc: resource: "@NeoFusionJsonRpcBundle/Controller/ServerController.php" prefix: / type: annotation
Step 5: Register compiler
# src/Kernel.php
protected function build(ContainerBuilder $container)
{
$container->addCompilerPass(new JsonRpcPass());
}