Archives


Master Symfony2 fundamentals

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

Discover the SensioLabs Support

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

Fabien Potencier
New in Symfony 2.4: Better Error Messages for missing Classes and Functions
by Fabien Potencier – August 28, 2013 – 4 comments

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.

Comments RSS

  • Ala eddine khefifi
    #1 Ala eddine khefifi said on the 2013/08/28 at 19:41
    Awesome, that will be very useful
  • Mohanraj
    #2 Mohanraj said on the 2013/08/29 at 07:39
    Hi Fabi,

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

    Is it Possible with this?
  • Quentin Fahrner
    #3 Quentin Fahrner said on the 2013/08/29 at 09:47
    Amazing !
  • Luis Cordova
    #4 Luis Cordova said on the 2013/08/29 at 09:47
    way to go, good job Beau and guys!