Jean-François Simon
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:

1
2
3
4
5
$ ./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:

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

Want to learn more about a specific route?

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

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

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

You can restrict to only one service:

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

And getting defined parameters is as easy as running:

1
$ ./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:

1
2
$ ./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?

Published in #Living on the edge