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

robbo's avatar
Level 1

Getting error in Container.php line 779: Class request does not exist

Hello,

I cloned a repo created by the previous developer at work. It's my first time working on Laravel and I can't for the life of me find out why this error is being triggered. I've ran composer install, composer update, composer self-update. I've tried running a few artisan commands but they will not run. I also tried looking for places where perhaps Illuminate\Http\Request; was not specified. Any help is truly appreciated. This is the error I'm getting:

Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

In Container.php line 779:
                                
  Class request does not exist  
                                
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

These are the log errors:

[2019-03-04 00:30:55] laravel.ERROR: Class request does not exist {"exception":"[object] (ReflectionException(code: -1): Class request does not exist at /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:779)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('request')
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(658): Illuminate\Container\Container->build('request')
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(609): Illuminate\Container\Container->resolve('request', Array)
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(759): Illuminate\Container\Container->make('request', Array)
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(121): Illuminate\Foundation\Application->make('request', Array)
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(731): app('request')
#6 /var/www/html/config/l5-swagger.php(158): request()
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(72): require('/var/www/html/c...')
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(39): Illuminate\Foundation\Bootstrap\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\Foundation\Application), Object(Illuminate\Config\Repository))
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(211): Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap(Object(Illuminate\Foundation\Application))
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(297): Illuminate\Foundation\Application->bootstrapWith(Array)
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(120): Illuminate\Foundation\Console\Kernel->bootstrap()
#12 /var/www/html/app/Console/Kernel.php(47): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/artisan(37): App\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 {main}
"}

This is the composer.json file:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "jenssegers/agent": "^2.6",
        "juampi92/api-resources": "^1.1",
        "lanin/laravel-api-debugger": "^3.1",
        "laravel/framework": "5.7.*",
        "laravel/passport": "^7.0",
        "laravel/tinker": "^1.0",
        "ramsey/uuid": "^3.8",
        "silber/bouncer": "v1.0.0-rc.4"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^2.5",
        "beyondcode/laravel-dump-server": "^1.0",
        "darkaonline/l5-swagger": "^5.7",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.8",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "autoload": {
        "files": [
            "app/Support/helpers.php"
        ],
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ],
        "post-update-cmd": [
            "Illuminate\Foundation\ComposerScripts::postUpdate",
            "php artisan ide-helper:generate",
            "php artisan ide-helper:meta"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}
0 likes
7 replies
bobbybouwmann's avatar

It looks like you typed request instead of Request. Laravel is case sensitive for classes.

1 like
bobbybouwmann's avatar

Another problem might be the permissions on the bootstrap/cache directory. You need to make sure you have write permissions to that directory (664)

2 likes
agilasadi's avatar

We can help you better if you share some of the code, it's hard to guess. Other than that as @bobbybouwmann mentioned, you might have defined Request class wrongly

robbo's avatar
Level 1

@AGILASADI - Hi Agilasadi,

Just added the composer.json contents to the question. Not sure if that helps.

robbo's avatar
Level 1

@BOBBYBOUWMANN - Just tried this. Error keeps triggering. I'll try to look for request vs Request once more. Thank you.

Snapey's avatar
Snapey
Best Answer
Level 122

it appears to be something in config/L5-swagger.php

robbo's avatar
Level 1

@SNAPEY - OMG! Thank you!! That was it.

I'll try to figure our what that file is missing or if there's any syntax errors.

Please or to participate in this conversation.