1 | <?php |
||
11 | class Handler extends ExceptionHandler |
||
12 | { |
||
13 | /** |
||
14 | * A list of the exception types that should not be reported. |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $dontReport = [ |
||
19 | \Illuminate\Auth\AuthenticationException::class, |
||
20 | \Illuminate\Auth\Access\AuthorizationException::class, |
||
21 | \Symfony\Component\HttpKernel\Exception\HttpException::class, |
||
22 | \Illuminate\Database\Eloquent\ModelNotFoundException::class, |
||
23 | \Illuminate\Session\TokenMismatchException::class, |
||
24 | \Illuminate\Validation\ValidationException::class, |
||
25 | ]; |
||
26 | |||
27 | /** |
||
28 | * Report or log an exception. |
||
29 | * |
||
30 | * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
||
31 | * |
||
32 | * @param \Exception $exception |
||
33 | * @return void |
||
34 | */ |
||
35 | public function report(Exception $exception) |
||
39 | |||
40 | /** |
||
41 | * Render an exception into an HTTP response. |
||
42 | * |
||
43 | * @param \Illuminate\Http\Request $request |
||
44 | * @param \Exception $exception |
||
45 | * @return \Illuminate\Http\Response |
||
46 | */ |
||
47 | public function render($request, Exception $exception) |
||
69 | |||
70 | /** |
||
71 | * Convert an authentication exception into an unauthenticated response. |
||
72 | * |
||
73 | * @param \Illuminate\Http\Request $request |
||
74 | * @param \Illuminate\Auth\AuthenticationException $exception |
||
75 | * @return \Illuminate\Http\Response |
||
76 | */ |
||
77 | protected function unauthenticated($request, AuthenticationException $exception) |
||
85 | } |
||
86 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: