Perhaps a problem with your composer or PHP version ?
Laravel: Error "Target class [request] does not exist" after cloning project and running composer install
I recently cloned a Laravel project from a Git repository that was previously worked on by another developer. After successfully running composer install, I encountered the following warning and error:
Package maximebf/debugbar is abandoned, you should avoid using it. Use php-debugbar/php-debugbar instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
In Container.php line 879:
Target class [request] does not exist.
In Container.php line 877:
Class request does not exist.
I also get the same error when I try to run php artisan serve.
Steps I took:
-
Cloned the repository
-
Ran
composer install(no other changes made) -
Tried
php artisan serve, but the same "Class request does not exist" error appears
Composer.json
{
"name": "financialplugins/stake",
"description": "PowerGames - online casino gaming platform.",
"keywords": ["PowerGames", "casino", "games"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.3.0",
"ext-bcmath": "*",
"ext-gmp": "*",
"ext-json": "*",
"ext-zip": "*",
"barryvdh/laravel-ide-helper": "2.8.2",
"enlightn/enlightn": "^1.14",
"fideloper/proxy": "^4.0",
"fruitcake/laravel-cors": "^1.0",
"laravel/framework": "^8.0",
"laravel/helpers": "^1.4",
"laravel/sanctum": "^2.0",
"laravel/socialite": "^5.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^3.0",
"nao-pon/flysystem-google-drive": "~1.1",
"pusher/pusher-php-server": "^4.1",
"sentry/sentry-laravel": "^2.4",
"spatie/flysystem-dropbox": "^1.2",
"ext-curl": "*",
"guzzlehttp/guzzle": "^7.0.1"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.5",
"beyondcode/laravel-dump-server": "^1.0",
"doctrine/dbal": "^2.9",
"facade/ignition": "^2.3.6",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": [
"barryvdh/laravel-debugbar"
]
}
},
"autoload": {
"files": [
"app/Helpers/Helpers.php"
],
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php artisan jwt:secret --force --ansi"
]
}
}
Is it possible that there's a misconfigured binding or the service container is trying to resolve a class alias that doesn’t exist? Any guidance would be really appreciated.
Please or to participate in this conversation.