{"id":20144681,"url":"https://github.com/zored/speech","last_synced_at":"2026-05-15T07:04:33.162Z","repository":{"id":57091941,"uuid":"88264098","full_name":"zored/speech","owner":"zored","description":"JSON-RPC 2.0 for PHP. With Symfony 2.0 to 3.0 support.","archived":false,"fork":false,"pushed_at":"2017-04-14T19:44:53.000Z","size":74,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T10:50:45.270Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zored.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-14T12:01:30.000Z","updated_at":"2018-06-14T12:57:10.000Z","dependencies_parsed_at":"2022-08-22T20:41:02.023Z","dependency_job_id":null,"html_url":"https://github.com/zored/speech","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zored%2Fspeech","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zored%2Fspeech/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zored%2Fspeech/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zored%2Fspeech/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zored","download_url":"https://codeload.github.com/zored/speech/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241587929,"owners_count":19986628,"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":[],"created_at":"2024-11-13T22:11:36.004Z","updated_at":"2026-05-15T07:04:28.116Z","avatar_url":"https://github.com/zored.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Speech\n## JSON-RPC 2.0 for PHP\n[![Build Status](https://travis-ci.org/zored/speech.svg?branch=master)](https://travis-ci.org/zored/speech)\n[![Latest Stable Version](https://poser.pugx.org/zored/speech/v/stable)](https://packagist.org/packages/zored/speech)\n\nBundle for JSON-RPC 2.0.\nYou can use as **standalone library**. Or with **Symfony**.\n\n## Features\n- Validation. Based on [Symfony Validator component](https://github.com/symfony/validator).\n- Deserialization. Based on [JMS](https://github.com/schmittjoh/serializer).\n- Customization. Change your rules for **[JSON-RPC 2.0](http://json-rpc.org/wiki/specification)**.\n\n## Use\n### Symfony\n- Install package: `composer require zored/speech`.\n- Add bundle `new Zored\\SpeechBundle\\ZoredSpeechBundle()` to your Symfony kernel `app/AppKernel.php`.\n- Add route to default endpoint: `routing.yml`:\n    ```yaml\n    json_rpc:\n        defaults: { _controller: ZoredSpeechBundle:Default:jsonRpc }\n        methods: [POST] # Or GET for Zored RPC.\n        path: /json-rpc\n    ```\n- Add service with your JSON-RPC methods in `services.yml`:\n    ```yaml\n    services:\n        your.service:\n            # Replace with your own class:\n            class: 'Zored\\SpeechBundle\\Test\\JsonRpc\\Greeter'\n    ```\n- Allow this service to run in default controller via `parameters.yml`:\n    ```yaml\n    parameters:\n      zored.speech.controller.context.service_ids: ['your.service']\n    ```\n- Clear caches.\n- Test:\n    ```bash\n    curl http://example.com/json-rpc/ \\\n        --data '{\"id\":\"1\", \"method\":\"your.service:greet\", \"params\":{\"person\":{\"name\":\"bob\",\"age\":19}},\"jsonrpc\":\"2.0\"}'\n    ```\n\n### Standalone library\n- See example in [`web/index.php`](web/index.php)\n- Run there server with `php -S 127.0.0.1:8080`\n- Test:\n    ```bash\n    curl http://127.0.0.1:8080 \\\n        --data '{\"id\":\"1\", \"method\":\"your.service:greet\", \"params\":{\"person\":{\"name\":\"bob\",\"age\":19}},\"jsonrpc\":\"2.0\"}'\n    ```\n\n## What's next?\n- See [default controller](src/Controller/DefaultController.php) if you need multiple JSON-RPC endpoints.\n- See [tests](test/Endpoint/EndpointTest.php) to know how it works.\n\n## Inside\n- Your request JSON string goes to [endpoint](src/Endpoint/Endpoint.php) which handles it and returns Symfony response.\n- Endpoint chooses which [request passer](src/Request/Passer/RequestPasserInterface.php) can pass JSON string to request handler.\n    - There are [single](src/Request/Passer/SingleRequestPasser.php) for `{}` and [batch](src/Request/Passer/BatchRequestPasser.php) for `[{},{}]` passers enabled by default. \n- Request passer also deserializes JSON to object and validates it.\n- Request passer passes request object to [request handler](src/Request/Handler/RequestHandlerInterface.php) that pushes request somewhere to get response.\n    - Now [service handler](src/Request/Handler/ServiceHandler.php) is used to:\n        - Deserialize request `params` if set with [parameter converter](src/Request/Handler/RequestHandlerInterface.php).\n        - Call public method of service with these params. **Services are restricted with [`ServiceContext`](src/Endpoint/Context/ServiceContext.php)**. For default controller see `zored.speech.controller.context` parameter.\n        - Wait for `array` or [`AbstractResponse`](src/Response/Entity/AbstractResponse.php).\n- Request then passed back and serialized to array.\n\n## Events \nYou can see available events [here](src/Event/EventNameInterface.php).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzored%2Fspeech","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzored%2Fspeech","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzored%2Fspeech/lists"}