{"id":15490139,"url":"https://github.com/yoanm/symfony-jsonrpc-http-server","last_synced_at":"2025-04-22T19:07:04.411Z","repository":{"id":31457935,"uuid":"127956249","full_name":"yoanm/symfony-jsonrpc-http-server","owner":"yoanm","description":"Symfony JSON-RPC HTTP Server to convert an HTTP json-rpc request into HTTP json-rpc response","archived":false,"fork":false,"pushed_at":"2024-03-31T14:40:22.000Z","size":196,"stargazers_count":11,"open_issues_count":5,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T19:06:56.909Z","etag":null,"topics":["json-rpc","jsonrpc-server-sdk","php","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yoanm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG-3.1.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-03T19:08:56.000Z","updated_at":"2025-04-07T11:48:17.000Z","dependencies_parsed_at":"2024-03-13T13:27:57.170Z","dependency_job_id":"4b0d1453-3673-4581-9d3c-3aaf90eb9806","html_url":"https://github.com/yoanm/symfony-jsonrpc-http-server","commit_stats":{"total_commits":68,"total_committers":5,"mean_commits":13.6,"dds":0.05882352941176472,"last_synced_commit":"4d449dac2e00225b0390dad9427a336c03098a68"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoanm%2Fsymfony-jsonrpc-http-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoanm%2Fsymfony-jsonrpc-http-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoanm%2Fsymfony-jsonrpc-http-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoanm%2Fsymfony-jsonrpc-http-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoanm","download_url":"https://codeload.github.com/yoanm/symfony-jsonrpc-http-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250306638,"owners_count":21408926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-rpc","jsonrpc-server-sdk","php","symfony-bundle"],"created_at":"2024-10-02T07:09:29.515Z","updated_at":"2025-04-22T19:07:04.390Z","avatar_url":"https://github.com/yoanm.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symfony JSON-RPC server\n\n[![License](https://img.shields.io/github/license/yoanm/symfony-jsonrpc-http-server.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server)\n[![Code size](https://img.shields.io/github/languages/code-size/yoanm/symfony-jsonrpc-http-server.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server)\n[![Dependabot Status](https://api.dependabot.com/badges/status?host=github\\\u0026repo=yoanm/symfony-jsonrpc-http-server)](https://dependabot.com)\n\n[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/symfony-jsonrpc-http-server.svg?label=Scrutinizer\\\u0026logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server/build-status/master)\n[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/yoanm/symfony-jsonrpc-http-server/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server/?branch=master)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/8f39424add044b43a70bdb238e2f48db)](https://www.codacy.com/gh/yoanm/symfony-jsonrpc-http-server/dashboard?utm_source=github.com\\\u0026utm_medium=referral\\\u0026utm_content=yoanm/symfony-jsonrpc-http-server\\\u0026utm_campaign=Badge_Grade)\n\n[![CI](https://github.com/yoanm/symfony-jsonrpc-http-server/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/yoanm/symfony-jsonrpc-http-server/actions/workflows/CI.yml)\n[![codecov](https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server/branch/master/graph/badge.svg?token=NHdwEBUFK5)](https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server)\n[![Symfony Versions](https://img.shields.io/badge/Symfony-v4.4%20%2F%20v5.4%2F%20v6.x-8892BF.svg?logo=github)](https://symfony.com/)\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/symfony-jsonrpc-http-server.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server)\n[![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/symfony-jsonrpc-http-server.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server)\n\nSymfony JSON-RPC HTTP Server to convert an HTTP json-rpc request into HTTP json-rpc response.\n\nSymfony bundle for [`yoanm/jsonrpc-server-sdk`](https://github.com/yoanm/php-jsonrpc-server-sdk)\n\nSee [yoanm/symfony-jsonrpc-params-validator](https://github.com/yoanm/symfony-jsonrpc-params-validator) for params validation.\n\nSee [yoanm/symfony-jsonrpc-http-server-doc](https://github.com/yoanm/symfony-jsonrpc-http-server-doc) for documentation generation.\n\n## Versions\n\n*   Symfony v3/4 - PHP \u003e=7.1 : `^2.0`\n\n    ⚠️⚠️ `v2.1.0` and `v2.1.1` were badly taggued, used `v3.0.0` instead ! ⚠️⚠️\n\n*   Symfony v4/5 - PHP \u003e=7.2 : `~3.0.0`\n\n*   Symfony v4/5 - PHP \u003e=7.3 : `^3.1`\n\n*   Symfony v4.4/5.4 - PHP ^8.0 : `^3.2`\n\n*   Symfony v4.4/5.4/6.x - PHP ^8.0 : `^3.3`\n\n## How to use\n\nOnce configured, your project is ready to handle HTTP `POST` request on `/json-rpc` endpoint.\n\nSee below how to configure it.\n\n## Configuration\n\nBundle requires only one thing :\n\n*   JSON-RPC Methods which are compatible with [`yoanm/jsonrpc-server-sdk`](https://raw.githubusercontent.com/yoanm/php-jsonrpc-server-sdk)\n\nIt comes with [built-in method resolver](./src/Resolver/MethodResolver.php) which use a [service locator](https://symfony.com/doc/3.4/service_container/service_subscribers_locators.html#defining-a-service-locator). Using a service locator allow to load (and so instanciate dependencies, dependencies of dependencies, etc) method only when required (usually only one method is required by request, except for batch requests which will load one or more methods).\n\n*[Behat demo app configuration folders](./features/demo_app/) can be used as examples.*\n\n*   Add the bundles in your `config/bundles.php` file:\n    ```php\n    // config/bundles.php\n    return [\n        ...\n        Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle::class =\u003e ['all' =\u003e true],\n        Yoanm\\SymfonyJsonRpcHttpServer\\JsonRpcHttpServerBundle::class =\u003e ['all' =\u003e true],\n        ...\n    ];\n    ```\n\n*   Add the following in your routing configuration :\n    ```yaml\n    # config/routes.yaml\n    json-rpc-endpoint:\n      resource: '@JsonRpcHttpServerBundle/Resources/config/routing/endpoint.xml'\n    ```\n\n*   Add the following in your configuration :\n    ```yaml\n    # config/config.yaml\n    framework:\n      secret: '%env(APP_SECRET)%'\n\n    json_rpc_http_server: ~\n    # Or the following in case you want to customize endpoint path\n    #json_rpc_http_server:\n    #  endpoint: '/my-custom-endpoint' # Default to '/json-rpc'\n    ```\n\n### JSON-RPC Method mapping\n\nIn order to inject yours JSON-RPC method into the server add the tag `json_rpc_http_server.jsonrpc_method` and the key/value `method` like following example :\n\n```yaml\nservices:\n   method-a.service-id:\n      class: Method\\A\\Class\n      tags:\n       - { name: 'json_rpc_http_server.jsonrpc_method', method: 'method-a' }\n       - { name: 'json_rpc_http_server.jsonrpc_method', method: 'method-a-alias' }\n```\n\n### Methods mapping aware\n\nIn case you want to be aware of which methods are registered inside the JSON-RPC server, you can use the `json_rpc_http_server.method_aware`. Your class must implements `JsonRpcMethodAwareInterface`.\n\n```php\nuse Yoanm\\JsonRpcServer\\Domain\\JsonRpcMethodAwareInterface;\nuse Yoanm\\JsonRpcServer\\Domain\\JsonRpcMethodInterface;\n\nclass MappingCollector implements JsonRpcMethodAwareInterface\n{\n  /** @var JsonRpcMethodInterface[] */\n  private $mappingList = [];\n\n  public function addJsonRpcMethod(string $methodName, JsonRpcMethodInterface $method): void\n  {\n    $this-\u003emappingList[$methodName] = $method;\n  }\n\n  /**\n   * @return JsonRpcMethodInterface[]\n   */\n  public function getMappingList() : array\n  {\n    return $this-\u003emappingList;\n  }\n}\n```\n\n```yaml\nmapping_aware_service:\n  class: App\\Collector\\MappingCollector\n  tags: ['json_rpc_http_server.method_aware']\n```\n\n## Debug mode\n\nYou can setup 'debug' mode for the JSON-RPC server, which allows display of verbose error information within the response JSON body.\nThis information contains actual exception class name, code, message and stack trace.\n\n\u003e Note: you should never enable 'debug' mode in 'production' environment, since it will expose vital internal information to the API consumer.\n\nConfiguration example:\n\n```yaml\n# file 'config/packages/json_rpc.yaml'\njson_rpc_http_server:\n  endpoint: '/json-rpc'\n  debug:\n    enabled: false\n    max_trace_size: 10\n    show_trace_arguments: true\n    simplify_trace_arguments: true\n\nwhen@dev:\n  json_rpc_http_server:\n    debug:\n      enabled: true\n\nwhen@test:\n  json_rpc_http_server:\n    debug:\n      enabled: true\n```\n\n## Contributing\n\nSee [contributing note](./CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoanm%2Fsymfony-jsonrpc-http-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoanm%2Fsymfony-jsonrpc-http-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoanm%2Fsymfony-jsonrpc-http-server/lists"}