After an update from laravel/framework 5.7.9 to version 5.7.10, site won't open anymore with following error in nginx/apache error log (tested on both):
PHP message: PHP Fatal error: Uncaught ReflectionException: Class request does not exist in localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php:779
Stack trace:0 localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('request')
1 localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php(658): Illuminate\Container\Container->build('request')
2 localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php(609): Illuminate\Container\Container->resolve('request', Array)
3 localhost/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(733): Illuminate\Container\Container->make('request', Array)
4 localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php(1222): Illuminate\Foundation\Application->make('request')
5 localhost/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(112): Illuminate\Container...
If i downgrade to 5.7.9 everything works fine. No code was changed between, only the framework was updated.
Update laravel/framework to version 5.7.10.
Please post the whole stacktrace.
I'd love to, but that is all i got. On every server (three of them), stack trace has been stripped for some reason.
Are you using configuration caching (php artisan config:cache
)?
Here is the full stack trace:
PHP Fatal error: Uncaught ReflectionException: Class request does not exist in localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php:779
Stack trace:0 localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('request')
1 localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php(658): Illuminate\Container\Container->build('request')
2 localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php(609): Illuminate\Container\Container->resolve('request', Array)
3 localhost/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(733): Illuminate\Container\Container->make('request', Array
4 localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php(1222): Illuminate\Foundation\Application->make('request')
5 localhost/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(112): Illuminate\Container\Container->offsetGet('request')
6 in localhost/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 779
Yes i do use config caching, but i never had an issue, and i am using laravel in my project since 5.4.
Just to rule it out: Run php artisan config:clear
.
Unfortunately, that did not solve the issue.
I notice it says Class request
and not Class Request
Looks like a local error, where you have incorrectly named a class somewhere. It might work on your local machine (i.e. Windows) - but on production it might be case sensitive (i.e. Ubuntu).
You mention that you see the error in "nginx/apache error log", do you have another error log with the full stacktrace? Like the one in the application's storage/logs folder?
The request is added to the container very early in the lifecycle. You can found it in public/index.php in a call to $kernel->handle
which calls Kernel::sendRequestThroughRouter
. If it fails before this, then I would suspect you have another problem than just a missing entry in the container.
Anyhow, check for a log file that contains all the nested exceptions too, you probably have some. Also, try editing HandleExceptions::handleException
to var_dump the message and stacktrace to see what's going on. This would give you details in case you do have a problem with your exception handler.
All the development is done on Ubuntu, server runs on Ubuntu. I have also noticed that it is not Request
but request
class that laravel is complaining about.
But if there is an typo somewhere, shouldn't that cause problems with any version, not just the latest?
Anyway, it was late yesterday to do extensive debugging, but now i can do it and see if its local, since nobody else reported it, and the error pops out as soon as i try to open the site, which means that it is triggered right on start.
Closing the issue, problem was definitely local. Permissions on bootstrap/cache
folder needed to be adjusted(once again) to allow proper functioning.
FWIW, I'm experiencing something similar, and getting the same error. For my particular case, the stack trace leads through this code in Illuminate\Http\Resources\Json\JsonResource
:
public function response($request = null)
{
return $this->toResponse(
$request ?: Container::getInstance()->make('request')
);
}
Now, I'm not (yet) sure why this is breaking. For me, it's while running tests. I can make one HTTP request from my test and all is well, then second one triggers this same error, however.
I'm not sure that this is worth re-opening...yet. I've spent a lot of time on this so far, but I've not made much headway. Also, I'm on PHPUnit 7.5.16 (although I just switched back from 8.x thinking it may have had something to do with PHPUnit) and Laravel Framework 6.0.3.
Sorry...I also wanted to point out with the code above that the difference between request
and Request
isn't necessarily because of an error on the user's part. (I'm experiencing similar errors with config
.
Another interesting note...I've got around 125 tests across 6 test classes that work fine, making HTTP request after HTTP request. But, my 7th test class seems to have a problem. There are few differences in the test classes themselves. There's a lot of repetitive tests for the various API resources. The code for the resource with the failing tests does do some things differently....like dispatching jobs.
I've still got to dig a bit more...and other than the error being the same and coming from a line of code that seems to work fine everywhere else, I'm not sure my particular problem is related...yet.
make sure to use Laravel Controller and extend it this actulally the issue for me
When I have this issue, I just composer update
and it goes away.
Okay so I encountered the same issue here. I feel the pain.
@staudenmeir 's php artisan config:clear
worked for me, but before that I did try a composer update
this boggles me. Although I am new to the intricacies of docker and environments.
Hope this helps someone out there, I nearly gave up tonight..
I notice it says
Class request
and notClass Request
Looks like a local error, where you have incorrectly named a class somewhere. It might work on your local machine (i.e. Windows) - but on production it might be case sensitive (i.e. Ubuntu).
This was my problem, you saved my day. Thank you
or try clearing bootstrap/cache dir.
PHP Fatal error: Declaration of Illuminate\Foundation\Exceptions\Handler::repor
t(Exception $e) must be compatible with Illuminate\Contracts\Debug\ExceptionHand
ler::report(Throwable $e) in C:\xampp\htdocs\javashop\vendor\laravel\framework\s
rc\Illuminate\Foundation\Exceptions\Handler.php on line 24
PHP Fatal error: Uncaught ReflectionException: Class App\Exceptions\Handler doe
s not exist in C:\xampp\htdocs\javashop\vendor\laravel\framework\src\Illuminate\
Container\Container.php:805
Stack trace:
ntainer.php(805): ReflectionClass->__construct('App\Exceptions\...')
ntainer.php(687): Illuminate\Container\Container->build('App\Exceptions\...')
pplication.php(796): Illuminate\Container\Container->resolve('App\Exceptions\.
..', Array, false)
ntainer.php(265): Illuminate\Foundation\Application->resolve('App\Exceptions\.
..', Array, false)
ntainer.php(801): Illuminate\Container\Container->Illuminate\Container{closure}
(Object(Illu in C:\xampp\htdocs\javashop\vendor\laravel\framework\src\Illuminate
\Container\Container.php on line 807
can anyone help me with this error
@Shailabk24 Did you recently upgrade to Laravel 7? Your error looks like they are documented in the upgrade notes. https://laravel.com/docs/7.x/upgrade#symfony-5-related-upgrades
@Shailabk24 Did you recently upgrade to Laravel 7? Your error looks like they are documented in the upgrade notes. https://laravel.com/docs/7.x/upgrade#symfony-5-related-upgrades
yeah my laravel version is 7.2.31 but my php artisan isn't working at all
@Shailabk24 Did you recently upgrade to Laravel 7? Your error looks like they are documented in the upgrade notes. https://laravel.com/docs/7.x/upgrade#symfony-5-related-upgrades
sir upgraded the latest version but now again there's an error
PHP Fatal error: Uncaught TypeError: Argument 1 pass
ed to Illuminate\Foundation\Exceptions\Handler::shouldntReport() must be an inst
ance of Illuminate\Foundation\Exceptions\Exception, instance of TypeError given,
called in C:\xampp\htdocs\javashop\vendor\laravel\framework\src\Illuminate\Foun
dation\Exceptions\Handler.php on line 61 and defined in C:\xampp\htdocs\javashop
\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php:91
Stack trace:
xceptions\Handler.php(61): Illuminate\Foundation\Exceptions\Handler->shouldntRep
ort(Object(TypeError))
n\Exceptions\Handler->report(Object(TypeError))
ootstrap\HandleExceptions.php(88): App\Exceptions\Handler->report(Object(TypeErr
or))
Exception(Object(TypeE in C:\xampp\htdocs\javashop\vendor\laravel\framework\src\
Illuminate\Foundation\Exceptions\Handler.php on line 91
[Thu Jun 11 20:09:21 2020] PHP Fatal error: Uncaught TypeError: Argument 1 pass
ed to Illuminate\Foundation\Exceptions\Handler::shouldntReport() must be an inst
ance of Illuminate\Foundation\Exceptions\Exception, instance of Symfony\Componen
t\ErrorHandler\Error\FatalError given, called in C:\xampp\htdocs\javashop\vendor
\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php on line 61 a
nd defined in C:\xampp\htdocs\javashop\vendor\laravel\framework\src\Illuminate\F
oundation\Exceptions\Handler.php:91
Stack trace:
xceptions\Handler.php(61): Illuminate\Foundation\Exceptions\Handler->shouldntRep
ort(Object(SymfonyComponent\ErrorHandler\Error\FatalError))
n\Exceptions\Handler->report(Object(SymfonyComponent\ErrorHandler\Error\FatalEr
ror))
ootstrap\HandleExceptions.php(88): App\Exceptions\Handler->report(Object( in C:\
xampp\htdocs\javashop\vendor\laravel\framework\src\Illuminate\Foundation\Excepti
ons\Handler.php on line 91
please help me out anyone
or try clearing /bootstrap/cache dir.
(delete the php files in that directory/folder)
It's hard to believe that this actually worked. :-o
I had already run php artisan optimize, config:cache, config:clear ....
How is it that optimize did not automatically delete those files before running? :-/
And the error Illuminate\Contracts\Container\BindingResolutionException
No help whatsoever.
This error happened from just installing Laravel Blog demo, and the UI Auth scaffold.
How is it that optimize did not automatically delete those files before running? :-/
Because it's a bit of a chicken and egg problem. I commented this elsewhere, but forget where :}
Those files are an intrinsic part for the "laravel boot" process and thus it happens already _before_ any artisan command is executed.
This means if an artisan command would exist to delete those files, and those cache files contain outdated information preventing Laravel from booting properly, you wouldn't get that far to actually delete them.
I am still getting this problem in a docker container and nothing works to fix it.
I notice it says
Class request
and notClass Request
Looks like a local error, where you have incorrectly named a class somewhere. It might work on your local machine (i.e. Windows) - but on production it might be case sensitive (i.e. Ubuntu).
100% worked for me. it was upper case lower case issue in my case. Thanks a lot
This is a code issue...In my app.php code i had used if (in_array(request(), ['X.X.X.X']))
{
return false;
}. this is what was causing the issue
Just search for request() in all of your code lines
Had a similar issue and referencing the Controller directly solved it. Route::get('/yourRoute', [App\Http\Controllers\SomeController::class, 'index'])->name('yourRoute');
Illuminate\Contracts\Container\BindingResolutionException
Target class [view.engine.resolver] does not exist.
at C:\Users\srall\Desktop\ecom\vendor\laravel\framework\src\Illuminate\Container\Container.php:811
807â–•
808â–• try {
809â–• $reflector = new ReflectionClass($concrete);
810â–• } catch (ReflectionException $e) {
➜ 811▕ throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
812â–• }
813â–•
814â–• // If the type is not instantiable, the developer is attempting to resolve
815â–• // an abstract type such as an Interface or Abstract Class and there is
1 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation{closure}(Object(Facade\Ignition\IgnitionServiceProvider))
2 C:\Users\srall\Desktop\ecom\vendor\laravel\framework\src\Illuminate\Container\Container.php:809
ReflectionException::("Class view.engine.resolver does not exist")
Tuve un problema similar y hacer referencia al controlador lo resolvió directamente.
Route::get('/yourRoute', [App\Http\Controllers\SomeController::class, 'index'])->name('yourRoute');
A mi me funciono asi esa solución, o colocando directamente la ruta del controlador ejemplo:
Route::get('/inicio','App\Http\Controllers\ProductosController@index');
Most helpful comment
Just to rule it out: Run
php artisan config:clear
.