diff --git a/.remarkignore b/.remarkignore new file mode 100644 index 0000000..22d0d82 --- /dev/null +++ b/.remarkignore @@ -0,0 +1 @@ +vendor diff --git a/.remarkrc b/.remarkrc new file mode 100644 index 0000000..0527df5 --- /dev/null +++ b/.remarkrc @@ -0,0 +1,6 @@ +{ + "plugins": [ + "remark-preset-lint-consistent", + "remark-preset-lint-recommended" + ] +} diff --git a/CHANGELOG-3.1.md b/CHANGELOG-3.1.md index 6d1fcd9..5028bfc 100644 --- a/CHANGELOG-3.1.md +++ b/CHANGELOG-3.1.md @@ -4,32 +4,32 @@ ### PHP Versions -* ๐Ÿ—‘๏ธ Drop PHP 7.2 support +* ๐Ÿ—‘๏ธ Drop PHP 7.2 support -* โœ”๏ธ PHP 7.3 +* โœ”๏ธ PHP 7.3 -* โœ”๏ธ PHP 7.4 +* โœ”๏ธ PHP 7.4 -* ๐Ÿš€ Add PHP 8.0 +* ๐Ÿš€ Add PHP 8.0 -* ๐Ÿš€ Add PHP 8.1 +* ๐Ÿš€ Add PHP 8.1 -* ๐Ÿงช Set PHP 8.2 for nightly +* ๐Ÿงช Set PHP 8.2 for nightly ### Symfony Versions -* โœ”๏ธ Symfony 4.4 +* โœ”๏ธ Symfony 4.4 -* โœ”๏ธ Symfony 5.4 +* โœ”๏ธ Symfony 5.4 -* ๐Ÿงช Set Symfony 6.0 for nightly +* ๐Ÿงช Set Symfony 6.0 for nightly ### Chore -* โœ๏ธ Add EditorConfig files +* โœ๏ธ Add EditorConfig files -* :octocat: Move CI from Travis to Github Action +* :octocat: Move CI from Travis to Github Action -* ๐Ÿ“Š Configure CodeCov +* ๐Ÿ“Š Configure CodeCov -* ๐Ÿ”ฌ Configure Codacy +* ๐Ÿ”ฌ Configure Codacy diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index c4f2952..0e3afd8 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation. Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting ## Our Responsibilities diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3789be7..a73ee93 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,33 +1,37 @@ # Contributing ## Getting Started - * Fork, then clone the repo: -```bash -git clone git@github.com:your-username/symfony-jsonrpc-http-server.git -```` - - * Make sure everything goes well: -```bash -make build -make test -``` - - * Make your changes (Add/Update tests according to your changes). - * Make sure tests are still green: -```bash -make test -``` - - * To check code coverage, launch -```bash -make coverage -``` - - * Push to your fork and [submit a pull request](https://github.com/yoanm/symfony-jsonrpc-http-server/compare/). - * Wait for feedback or merge. - - Some stuff that will increase your pull request's acceptance: - * Write tests. - * Follow PSR-2 coding style. - * Write good commit messages. - * Do not rebase or squash your commits when a review has been made. + +* Fork, then clone the repo: + ```bash + git clone git@github.com:your-username/symfony-jsonrpc-http-server.git + ``` + +* Make sure everything goes well: + ```bash + make build + make test + ``` + +* Make your changes (Add/Update tests according to your changes). + +* Make sure tests are still green: + ```bash + make test + ``` + +* To check code coverage, launch + ```bash + make coverage + ``` + +* Push to your fork and [submit a pull request](https://github.com/yoanm/symfony-jsonrpc-http-server/compare/). + +* Wait for feedback or merge. + +Some stuff that will increase your pull request's acceptance: + +* Write tests. +* Follow PSR-2 coding style. +* Write good commit messages. +* Do not rebase or squash your commits when a review has been made. diff --git a/README.md b/README.md index 43cbb81..7646402 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # Symfony JSON-RPC server + [![License](https://img.shields.io/github/license/yoanm/symfony-jsonrpc-http-server.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/symfony-jsonrpc-http-server.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server) -[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=yoanm/symfony-jsonrpc-http-server)](https://dependabot.com) +[![Dependabot Status](https://api.dependabot.com/badges/status?host=github\&repo=yoanm/symfony-jsonrpc-http-server)](https://dependabot.com) -[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/symfony-jsonrpc-http-server.svg?label=Scrutinizer&logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server/build-status/master) +[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/symfony-jsonrpc-http-server.svg?label=Scrutinizer\&logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server/build-status/master) [![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) -[![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&utm_medium=referral&utm_content=yoanm/symfony-jsonrpc-http-server&utm_campaign=Badge_Grade) +[![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\&utm_medium=referral\&utm_content=yoanm/symfony-jsonrpc-http-server\&utm_campaign=Badge_Grade) [![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) [![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) @@ -24,12 +25,13 @@ See [yoanm/symfony-jsonrpc-http-server-doc](https://github.com/yoanm/symfony-jso ## Versions -- Symfony v3/4 - PHP >=7.1 : `^2.0` +* Symfony v3/4 - PHP >=7.1 : `^2.0` + + โš ๏ธโš ๏ธ `v2.1.0` and `v2.1.1` were badly taggued, used `v3.0.0` instead ! โš ๏ธโš ๏ธ - โš ๏ธโš ๏ธ `v2.1.0` and `v2.1.1` were badly taggued, used `v3.0.0` instead ! โš ๏ธโš ๏ธ +* Symfony v4/5 - PHP >=7.2 : `~3.0.0` -- Symfony v4/5 - PHP >=7.2 : `~3.0.0` -- Symfony v4/5 - PHP >=7.3 : `^3.1` +* Symfony v4/5 - PHP >=7.3 : `^3.1` ## How to use @@ -39,45 +41,48 @@ See below how to configure it. ## Configuration -Bundle requires only one thing : - - JSON-RPC Methods which are compatible with [`yoanm/jsonrpc-server-sdk`](https://raw.githubusercontent.com/yoanm/php-jsonrpc-server-sdk) - +Bundle requires only one thing : + +* JSON-RPC Methods which are compatible with [`yoanm/jsonrpc-server-sdk`](https://raw.githubusercontent.com/yoanm/php-jsonrpc-server-sdk) + It 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). - + *[Behat demo app configuration folders](./features/demo_app/) can be used as examples.* - - Add the bundles in your `config/bundles.php` file: - ```php - // config/bundles.php - return [ - ... - Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], - Yoanm\SymfonyJsonRpcHttpServer\JsonRpcHttpServerBundle::class => ['all' => true], - ... - ]; - ``` - - - Add the following in your routing configuration : - ```yaml - # config/routes.yaml - json-rpc-endpoint: - resource: '@JsonRpcHttpServerBundle/Resources/config/routing/endpoint.xml' - ``` - - - Add the following in your configuration : - ```yaml - # config/config.yaml - framework: - secret: '%env(APP_SECRET)%' - - json_rpc_http_server: ~ - # Or the following in case you want to customize endpoint path - #json_rpc_http_server: - # endpoint: '/my-custom-endpoint' # Default to '/json-rpc' - ``` +* Add the bundles in your `config/bundles.php` file: + ```php + // config/bundles.php + return [ + ... + Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], + Yoanm\SymfonyJsonRpcHttpServer\JsonRpcHttpServerBundle::class => ['all' => true], + ... + ]; + ``` + +* Add the following in your routing configuration : + ```yaml + # config/routes.yaml + json-rpc-endpoint: + resource: '@JsonRpcHttpServerBundle/Resources/config/routing/endpoint.xml' + ``` + +* Add the following in your configuration : + ```yaml + # config/config.yaml + framework: + secret: '%env(APP_SECRET)%' + + json_rpc_http_server: ~ + # Or the following in case you want to customize endpoint path + #json_rpc_http_server: + # endpoint: '/my-custom-endpoint' # Default to '/json-rpc' + ``` ### JSON-RPC Method mapping + In 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 : + ```yaml services: method-a.service-id: @@ -88,6 +93,7 @@ services: ``` ### Methods mapping aware + In 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`. ```php @@ -121,4 +127,5 @@ mapping_aware_service: ``` ## Contributing + See [contributing note](./CONTRIBUTING.md)