Master Symfony2 fundamentals

Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).

Discover the SensioLabs Support

Access to the SensioLabs Competency Center for an exclusive and tailor-made support on Symfony

Fabien Potencier
New in Symfony 2.4: Better Console Integration with third-party Tools
by Fabien Potencier – October 14, 2013 – 3 comments

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?

Comments RSS

  • Christophe Coevoet
    #1 Christophe Coevoet said on the 2013/10/14 at 12:14
    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
  • Aman Varshney
    #2 Aman Varshney said on the 2013/10/14 at 17:55
    When r u releasing symfony 2.4??
  • Chris Sedlmayr
    #3 Chris Sedlmayr said on the 2013/10/15 at 09:30
    @Aman, November.
    You can check the release calculator