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.
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
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
"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.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.