HTTP API With Zero Per-Operation Controllers
Turns every operation of every worker registered in a Backbone package registry into an HTTP endpoint automatically — no per-operation controller code, self-documenting as HATEOAS resources and an OpenAPI 3.1 spec.
Why
Instead of writing POST /invoices/build → InvoiceController::build() by hand for each operation, you write one generic route pointing at one controller, and the URL path itself tells the package which worker method to call. The actual resolution and invocation is delegated entirely to derafu/backbone-dispatcher, which is transport-agnostic — this package only deals with the HTTP-specific concerns: parsing the route, listing packages/components/workers as browsable resources, serving OpenAPI documentation, and extracting parameters from the request body.
Installation
composer require derafu/backbone-api
The package provides dependency-injection wiring through backbone-api-services.yaml. The application supplies its Backbone package registry, concrete controller, HTTP response factory and route mounting.
Requirements
PHP 8.5+. Depends on derafu/backbone, derafu/backbone-dispatcher, psr/http-message, and psr/http-factory (for building the real failure response — a concrete PSR-17 implementation, e.g. nyholm/psr7, is the consuming application’s to provide).
Dependency Injection
Import the production configuration and supply the complete public API URL:
imports:
- { resource: '../vendor/derafu/backbone-api/resources/config/backbone-api-services.yaml' }
parameters:
derafu.backbone_api.url: 'https://example.com/api'
The URL is required and has no default. It is used unchanged for discovery links
and the OpenAPI server URL: the package does not append /api, trim slashes or
read env.APP_URL. A non-string value raises a translatable configuration
exception. In PHP, Explorer receives this full URL as its second constructor
argument instead of a ParameterBagInterface.
The parameter specifies the published URL; mounting the controller in the application’s routes remains the application’s responsibility.
The YAML imports Backbone Dispatcher’s shared composition. API’s RouterInterface
and DispatcherInterface are registered directly with their implementations;
Explorer, Documenter and HttpStatusResolver are internal concrete services.
Discovery, OpenAPI and execution share Dispatcher’s operation policy, which
exposes #[Operation] methods by default. Override
Derafu\BackboneDispatcher\Contract\OperationPolicyInterface to select a
different policy for all three.
The application must supply Derafu\Backbone\Contract\PackageRegistryInterface
and contribute any domain deserializers through Dispatcher’s tags. To configure
error metadata, set derafu.backbone_dispatcher.environment, .debug and
.project_dir; applications using Derafu Kernel can bind them to their existing
kernel parameters.
A concrete controller extending AbstractController belongs to the application.
It receives API’s shared dispatcher and status resolver, plus the application’s
Psr\Http\Message\ResponseFactoryInterface. The package does not select a PSR-17
implementation or install its own HTTP kernel.