Categories
Tags
API Audit Auditor Bundle Authentication Bulma Cache Castor ChatGPT Development Développement Web DevOps Docker Documentation Facebook FrankenPHP Fullstack GitHub Google JavaScript Linux Linux Mint MacBook Pro macOS Makefile OAuth2 OpenAI Optimization Performance PHP PHPUnit Pop!_OS Process Management Profile README Setup SQL Svelte Symfony Symfony Lock Technology Tutorial Verrouillage Web Development Workflow
125 words
1 minutes
Add Documentation to Your Symfony API
Today, we will see how to set up documentation for our API (which you can find in the previous article).
This will be extremely simple thanks to the package NelmioApiDocBundle.
Installation
To install it:
composer require nelmio/api-doc-bundleAnd that’s it! You can now navigate to /api/doc to view your API documentation.
If it doesn’t work, it might be because Twig is not installed. In that case, add it:
composer require twig assetIf it still doesn’t work, you need to declare the route in Symfony:
# config/routes/nelmio_api_doc.yaml
app.swagger_ui:
path: /api/doc
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }Result
This should give you:

Customizing the Documentation
If you want to learn more about customizing your API documentation to the fullest, you can check out the format specifications: https://swagger.io/specification/.
Source Code
You can find the complete source code on GitHub:
https://github.com/gponty/custom-api
