所以在决定创建此问题之前,我读了100篇关于此的帖子。
这个问题实际上是非常具体的,它是100%可重复的。
我创建了一个git分支,让我们调用它storeUpdate
,在这个分支中我创建了一个名为
app/Http/Controllers/Admin/BatchUpdateStoresController.php
具有以下内容:
namespace App\Http\Controllers\Admin;
use App\Http\Requests;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Repositories\BatchUpdateStores;
class BatchUpdateStoresController extends Controller
我将它添加到routes.php文件中:
app/Http/routes.php|214| $api->put('stores', 'Admin\BatchUpdateStoresController@update');
app/Http/routes.php|215| $api->post('stores', 'Admin\BatchUpdateStoresController@upload');
也是我的作曲家文件中的相关部分:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php",
"tests/Helpers/",
"tests/Traits/"
]
},
但是,当我将分支切换到另一个git分支,并且我尝试运行php artisan
时,我收到此错误:
[ReflectionException]类 App \ Http \ Controllers \ Admin \ BatchUpdateStoresController不存在
我发现上述错误很有趣,因为该文件确实不存在(注意实际文件是app/Http/Controllers/Admin/BatchUpdateStoresController.php
,所以app
!= App
,但我不是在我的composer.json文件的psr-4
部分中处理这个问题?
想法?
所有常见的东西包括:
composer dump-autoload
composer update
composer update --no-scripts
php artisan cache:clear
php artisan api:clear
php artisan route:clear
ReflectionException: Class App\Http\Controllers\Admin\BatchUpdateStoresController does not exist in /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Container/Container.php:749
Stack trace: #0 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Container/Container.php(749): ReflectionClass->__construct('App\\Http\\Contro...')
#1 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Container/Container.php(644): Illuminate\Container\Container->build('App\\Http\\Contro...', Array)
#2 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(709): Illuminate\Container\Container->make('App\\Http\\Contro...', Array)
#3 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Route.php(320): Illuminate\Foundation\Application->make('App\\Http\\Contro...')
#4 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Route.php(182): Dingo\Api\Routing\Route->makeControllerInstance()
#5 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Route.php(165): Dingo\Api\Routing\Route->mergeControllerProperties()
#6 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Route.php(144): Dingo\Api\Routing\Route->setupRouteProperties(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#7 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Router.php(652): Dingo\Api\Routing\Route->__construct(Object(Dingo\Api\Routing\Adapter\Laravel), Object(Illuminate\Foundation\Application), Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#8 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Router.php(714): Dingo\Api\Routing\Router->createRoute(Object(Illuminate\Routing\Route)) #9 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Router.php(744): Dingo\Api\Routing\Router->getRoutes()
#10 /Users/Shared/dev/php/toters-api/bootstrap/cache/routes.php(17): Dingo\Api\Routing\Router->setAdapterRoutes(Array)
#11 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(58): require('/Users/Shared/d...')
#12 [internal function]: Illuminate\Foundation\Support\Providers\RouteServiceProvider->Illuminate\Foundation\Support\Providers\{closure}(Object(Illuminate\Foundation\Application))
#13 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(808): call_user_func(Object(Closure), Object(Illuminate\Foundation\Application))
#14 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(757): Illuminate\Foundation\Application->fireAppCallbacks(Array)
#15 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application->boot()
#16 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#17 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(267): Illuminate\Foundation\Application->bootstrapWith(Array)
#18 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(113): Illuminate\Foundation\Console\Kernel->bootstrap()
#19 /Users/Shared/dev/php/toters-api/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #20
H 2。 udpdate
php artisan
会爆炸,所以你已经无法访问某些php artisan命令,例如php artisan route:clear
php artisan
运行php artisan route:clear
答案 0 :(得分:3)
如果不解决,请尝试php artisan route:clear
,请完整例外。
答案 1 :(得分:0)
由于php artisan已被卡住,你应该简单地删除bootstrap/cache/routes.php
(即如果你不想切换分支)
注意:,您必须运行
php artisan api:cache
或者它会抱怨没有路线