REST Bundle
composer require ufo-tech/rest-bundle
- PHP 8.4+
- Symfony 7.2+ · 8
- Built on JsonRpcBundle 10.4.3+
- Protocol REST · OpenAPI · Postman
- Type Symfony Bundle
- Category API
- License MIT
A REST API on top of JsonRpcBundle methods for Symfony 7.2+ / 8 (PHP 8.4+).
The RPC method stays the only implementation: the Symfony #[Route] attribute on an RPC procedure method makes it available under its own path and HTTP method. Parameters, validation, security, cache, events and documentation come from the RPC core; the bundle adds HTTP routes, the REST request and response format, RFC 9457 errors and OpenAPI 3.1 and Postman documents.
This documentation describes version 1.3, which is not tagged yet (the latest release is 1.2.0). What appeared only in 1.3 is marked on the pages. See the Changelog.
From method to REST
Your code
use Symfony\Component\Routing\Attribute\Route;
use Ufo\JsonRpcBundle\ApiMethod\Interfaces\IRpcService;
use Ufo\RpcObject\RPC;
#[RPC\Info('catalog')]
#[Route('/catalog', name: 'catalog')]
class CatalogApi implements IRpcService
{
#[Route('/items/{id}', name: 'item', methods: ['GET'])]
public function item(int $id): array
{
return ['id' => $id, 'title' => 'Book'];
}
}
Request
curl https://example.com/rest/catalog/items/42 \
-H 'Ufo-RPC-Token: change-me'
Response 200
{"id": 42, "title": "Book"}
What you get without extra code:
GET /restreturns an OpenAPI 3.1 document with thecatalog.itemoperation, andGET /rest/postmanreturns a Postman collection;- the value
42from the path is cast tointaccording to the method signature (since 1.3); - errors are RFC 9457 problem details with an HTTP status (
401,404,405,422, …); - the same method is still available via JSON-RPC:
POST /rpcwith"method": "catalog.item".
Why REST Bundle
- One implementation, two protocols. No REST controller per method, no second set of DTOs or separate validation.
#[RPC\Assertions],#[RPC\Cache],#[RPC\Lock]and events work for REST the same way as for JSON-RPC. - Explicit publishing. Only a method with
#[Route]gets into REST; the rest stay RPC-only (Routing). - API groups and versions. A separate REST entry point for each API group with its own methods, documentation and tokens; versions under
/v2/.... - Documentation from code. OpenAPI and Postman are built from the RPC service map: types, PHPDoc,
@throws, translations (API documentation). - No separate configuration. The bundle uses the
ufo_json_rpcsettings: security, project name, translations (Configuration).
Version 1.2
Tag 1.2.0, 2026-10-16.
Key changes
- Symfony 8 support:
^7.2|^8.0. - The Postman collection is built on the JsonRpcBundle
AbstractPostmanAdapter: namedREST: <project_name>, with a[group]suffix for a group other thangeneral. composer testandmake testrun PHPUnit.
What to keep in mind
- Tools that look up the Postman collection by name will see the new name.
Environment changes
ufo-tech/json-rpc-bundle^10.2.3.- Symfony ^7.2 or ^8.0.
Getting started
- Install the bundle:
composer require ufo-tech/rest-bundleand a routes file. - Add
#[Route]to the methods you need (Routing) and openGET /rest. - See how parameters are passed and how errors are returned.
- Set up security.
JSON-RPC batch, notifications and $rpc.callback are not available via REST: one HTTP request is one method call.
How the bundle works inside and how to extend it is described in the For developers section. When REST fits and when RPC does is covered in the article RPC, REST and GraphQL.