symfony/symfony — pull request #8156 by simensen (2013-05-28 17:38:37+00:00)
Title: [Debug] [WIP] Developer friendly Class Not Found and Undefined Function errors.

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a

Per a discussion with @weaverryan and others, I took a crack at enhancing the exception display for class not found errors and undefined function errors. It is not the cleanest solution but this is a work in progress to see whether or not following this path makes sense.

# Class Names

## Class Not Found: Unknown Class (Global Namespace)

```php
Attempted to load class 'WhizBangFactory' from the global namespace in foo.php line 12. Did you forget a use statement for this class?

## Class Not Found: Unknown Class (Full Namespace)

```php
Attempted to load class 'WhizBangFactory' from namespace 'Foo\Bar' in foo.php line 12. Do you need to 'use' it from another namespace?

## Class Not Found: Well Known Class (Global Namespace)

```php
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?

## Class Not Found: Well Known Class (Full Namespace)

```php
Attempted to load class 'Request' from namespace 'Foo\Bar' in foo.php line 12. Do you need to 'use' it from another namespace? Perhaps you need to add 'use Symfony\Component\HttpFoundation\Request' at the top of this file?

# Functions

## Undefined Function (Global Namespace)

```php
Attempted to call function 'test_namespaced_function' from the global namespace in foo.php line 12. Did you mean to call: '\acme\example\test_namespaced_function'?

## Undefined Function (Full Namespace)

```php
Attempted to call function 'test_namespaced_function' from namespace 'Foo\Bar\Baz' in foo.php line 12. Did you mean to call: '\acme\example\test_namespaced_function'?

## Undefined Function: Unknown Function (Global Namespace)

```php
Attempted to call function 'test_namespaced_function' from the global namespace in foo.php line 12.

## Undefined Function: Unknown Function (Full Namespace)

```php
Attempted to call function 'test_namespaced_function' from namespace 'Foo\Bar\Baz' in foo.php line 12.