Milos Cuculovic
Milos Cuculovic

Reputation: 20223

A good practice on how to debug a Symfony2 controller

I have an Symfony2 project and from time to time, I have PHP errors in my controller. In order to find out where is the error, I would like to debug the PHP code in the controller.

What do you think is the best practice to debug a controller in Symfony2?

Upvotes: 0

Views: 1715

Answers (1)

Wouter J
Wouter J

Reputation: 41934

The error page tells you many usefull things:

  • The error message - What is exactly going wrong? (and something: how can I solve this?)
  • The line number - On which line in the controller are things going wrong?
  • The exception name - Hover over the name to see the fully qualified namespace. It tells you on which component something is going wrong.
  • The trace - You can see a full trace path which tells you much usefull things: On which class/method is the exception thrown? Which methods are executed first?

Another good practise is to create tests for your controller, both functional and unit tests. Learn more about them in the documentation.


If you need more help, it is better to specify what error you get.

Upvotes: 1

Related Questions