New in Symfony 2.4: Better Error Messages for missing Classes and Functions

Contributed by
Beau Simensen and Fabien Potencier
in #8553.

This might be a recurring theme in the Symfony world, but each version of Symfony makes debugging common problems easier. This time, it's all about class not found and undefined function PHP errors.

Whenever PHP yells at you because of a missing class, you need to figure out the problem; it might be a typo, or you might have forgotten the use statement, or you might have forgotten to install a dependency.

As of Symfony 2.4, and only in the development environment, we give you better error messages than PHP when such errors occur, like when using the Request class without adding the corresponding use statement:

"Attempted to load class 'Request' from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add 'use Symfony\Component\HttpFoundation\Request' at the top of this file?"

Have a look at #8553 as the error message is tweaked depending on the context of the error.


Awesome, that will be very useful
Hi Fabi,

I need to write a error log file for Controller Repository Functions and Class errors.

Is it Possible with this?
Amazing !
way to go, good job Beau and guys!

Comments are closed.

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