Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nhadi's avatar
Level 1

Uncaught ReflectionException error after deploying my laravel application

version: 9 PHP version: PHP 8.0.30

I deployed my 9 application on localhost. I ran composer update all is but when I run my project on browser localhost/project/public/it threw this error:

This page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500

Stack trace:

PHP Fatal error: Uncaught Reflection Exception: Class "request" does not exist in vendor/laravel/framework/src/Illuminate/Container/Container 889

0 likes
4 replies
s4muel's avatar

i see "Class request" (with lowercase r), this seems to be a local error, possibly due to a class being misnamed in your code? Check if some class isn't named request instead of Request.

1 like
nhadi's avatar
Level 1

@s4muel Line number 889 There is this code:

public function build($concrete)
{
    // If the concrete type is actually a Closure, we will just execute it and
    // hand back the results of the functions, which allows functions to be
    // used as resolvers for more fine-tuned resolution of these objects.
    if ($concrete instanceof Closure) {
        return $concrete($this, $this->getLastParameterOverride());
    }

    try {
        $reflector = new ReflectionClass($concrete);
    } catch (ReflectionException $e) {
        throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
    }

    // If the type is not instantiable, the developer is attempting to resolve
    // an abstract type such as an Interface or Abstract Class and there is
    // no binding registered for the abstractions so we need to bail out.
    if (! $reflector->isInstantiable()) {
        return $this->notInstantiable($concrete);
    }

    $this->buildStack[] = $concrete;

    $constructor = $reflector->getConstructor();

    // If there are no constructors, that means there are no dependencies then
    // we can just resolve the instances of the objects right away, without
    // resolving any other types or dependencies out of these containers.
    if (is_null($constructor)) {
        array_pop($this->buildStack);

        return new $concrete;
    }

    $dependencies = $constructor->getParameters();

    // Once we have all the constructor's parameters we can create each of the
    // dependency instances and then use the reflection instances to make a
    // new instance of this class, injecting the created dependencies in.
    try {
        $instances = $this->resolveDependencies($dependencies);
    } catch (BindingResolutionException $e) {
        array_pop($this->buildStack);

        throw $e;
    }

    array_pop($this->buildStack);

    return $reflector->newInstanceArgs($instances);
}
1 like
nhadi's avatar
Level 1

@s4muel Line number Container.php 889 contain this code : $reflector = new ReflectionClass($concrete); There is no any 'request'

1 like
s4muel's avatar
s4muel
Best Answer
Level 50

@nhadi yes, of course, because that part of code tries to instantiate a request class which does not exist. that line is not relevant in this case, go through your code and check for that. might be simple enough to search your codebase for string request and eye scan the results.

something like this

Route::get('/user', function (request $request) {   //request instead of Request
    return $request->user();
});

or similar

1 like

Please or to participate in this conversation.