Out-of-the-box features make Sulu headless-ready
- Output content in multiple different formats (HTML, XML, JSON, …)
- Recognize format based on request
- Clean separation of content and output
- Extendable using Symfony know-how
- API provided by SuluHeadlessBundle
- Serves navigation structure via dedicated REST API endpoint
- Search endpoint
- Library makes building a React application easier
- Rendering engine can easily be swapped out
- Administration Live Preview also available in headless mode
- Reuse Sulu authentication for your custom API
- “Bring your own entity” can be used with your API
- Routing has already been taken care of
Plan your content model
Start by determining the fields that a content manager needs to work with, then define them in XML.
Build your JSON Twig template
The simplest solution is to use the json_encode filter in Twig to output the unescaped content, which is very easy to understand. This works because the file-name extension — e.g. “.json.twig” for JSON, or “.html.twig” — is automatically appended based on the request.
Start managing content
Your content managers have freedom to edit content in a structured manner with a user-friendly interface, and output can be generated in different formats (HTML, JSON, XML, and more).
Access the content with the “.json” suffix to retrieve JSON
Content can be accessed by adding the appropriate suffix to the request. For example, “.json” will return the JSON template (“.json.twig”).
See for yourself
We’d love to show you around Sulu so you can see how businesses benefit from its features and why developers love it. Get in touch and we’ll give you an online tour via video call.
Install the HeadlessBundle
Deliver JSON with the HeadlessBundle when you need more advanced functionality — although it’s one additional dependency you need to handle.
Build your XML template with the Headless Controller
The HeadlessBundle will take care of rendering the JSON output for you.
Start managing content
Your content managers have freedom to edit content in a structured manner with a user-friendly interface, and output can be generated in different formats (HTML, JSON, XML, and more).
Access the content with the “.json” suffix to retrieve JSON
Add the appropriate suffix to access content — ”.json” will return the JSON response.