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

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
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.
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.
Comments
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
I need to write a error log file for Controller Repository Functions and Class errors.
Is it Possible with this?