Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages showcasing Symfony with Docker, APIs, queues & async tasks, Webpack, SPAs, etc.

New in Symfony 2.4: Better Console Integration with third-party Tools

Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.

Contributed by
Jean-François Simon
in #7887.

Did you know that the Symfony console component provides tools to ease its integration in third-party tools? Out of the box, the Symfony console component gives all some tools to auto-discover register commands, their arguments, their help, and more:

$ ./app/console list --format=xml
$ ./app/console list --format=json

$ ./app/console help --format=xml
$ ./app/console help --format=json

This feature (which was already available in symfony1) is used by many text editors and IDEs to provide a GUI for Symfony commands.

Symfony 2.4 goes one step further by providing the same --format option on some debug commands like router::debug and container::debug.

Want to get all registered routes in a Symfony 2.4 app? Run:

$ ./app/console router:debug --format=xml

Want to learn more about a specific route?

$ ./app/console router:debug homepage --format=xml

And the same goes for the Container. Here is how to get all registered services:

$ ./app/console container:debug --format=xml

You can restrict to only one service:

$ ./app/console container:debug twig --format=xml

And getting defined parameters is as easy as running:

$ ./app/console container:debug --parameters --format=xml

Don't like XML? Use json instead of xml for the format!

Last, but not the least, the md format (Markdown) automatically generate documentation for your routes and services:

$ ./app/console router:debug --format=md
$ ./app/console container:debug --format=md

How will you use these new possibilities? Which tool are you going to create to ease your job?

Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.


The option name is wrong in the following sentence: "Symfony 2.4 goes one step further by providing the same --output option on some debug commands like router::debug and container::debug.". It should be --format, not --option
When r u releasing symfony 2.4??
@Aman, November.
You can check the release calculator

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.