Development Tools
Two optional tools. Both are skipped when the package they need is missing, so a production install is not affected. Install them in your project:
"require-dev": {
"symfony/maker-bundle": "^1.67",
"open-dxp/mate-extension": "^1.0"
}
Makers
An API endpoint always consists of the same set of classes. Only the handler carries logic, everything else is wiring.
bin/console make:api-query Product ProductList --collection --filter=order
bin/console make:api-command Account Unsubscribe --void --method=DELETE
The query variant creates Query, Action, QueryHandler and a ResponseEntity, the command variant
does the same for the write side. Both endpoints answer right away, only the handler needs your
logic. Every name is derived the way Naming Conventions describes,
so make:api-query Product Products --collection writes ListProductsAction and ProductsQuery.
Pass --action-name for an operation whose name cannot be derived.
--filter works for both and is repeatable. A name registered in
available_filter is wired up as it is, any other name becomes a new
filter class in the domain, and the command says which of the two happened. --help lists the names
this installation knows, including the ones installed bundles bring along.
The four remaining commands write a single class into src/Domain/<Domain>/:
bin/console make:response-entity Store StoreItem
bin/console make:response-entity Product EcommerceProduct --extends='OpenDxp\Bundle\HeadlessEcommerceBundle\Domain\Product\ResponseEntity\EcommerceProduct'
bin/console make:api-source-resolver Store OpeningHours
bin/console make:api-transformer Store DistanceInKm
bin/console make:api-filter Store NearBy
--extends writes the response_entity_mapping entry along with the class, into
config/packages/opendxp_headless_response_entities.yaml. A file of its own, because parsing and
dumping the file a project keeps its own configuration in would throw away comments and yaml
anchors. Symfony merges every file under config/packages, so the entry is just as effective
there, and it can be moved by hand at any time.
Response Entities explains when a source resolver fits and when a transformer.
Run bin/console make:api-query --help for all options.
Mate
Symfony AI Mate gives an AI agent tools
that read the running application. open-dxp/mate-extension adds the tools for OpenDXP, and this
bundle adds its own when Mate is installed. Set Mate up as the extension describes.
| Tool | Answers |
|---|---|
headless_api_endpoints | Every endpoint served right now, and where each one comes from |
headless_config | The headless configuration after every bundle and the project had their say |
headless_lint_response_entities | Response entities with a hole a generated client would trip over |
headless_search_setup | The OpenSearch hosts, the index of every search type and its listeners |
The bundle also ships three skills. mate-headless-api covers queries, commands, routes, message
extensions and filters. mate-headless-search covers search types, their index and the search
events. mate-headless-response-entities covers where a property value comes from,
overriding a bundle entity, nesting and OpenAPI attributes. The agent creates the classes with the
makers above.
vendor/bin/mate tools:list
Data sources
headless_api_endpoints reads the router, so it sees attribute routes and configured ones alike.
data_object_api_routes and api_search_types are expanded into api_routes while the
configuration is normalized, which the tool undoes by recomputing the names those entries produce.
It says for each endpoint whether it comes from an attribute, from api_routes, from a data object
route, from a search type or from a generated form schema route, and it points out api_routes
entries that declare an endpoint of the project itself, which is what the key is not for.