So I read like 100 post about this before deciding on creating this issue.
This problem is actually very specific and it's 100% reproducable.
I created a git branch lets call it storeUpdate
, and in this branch I created a file called
app/Http/Controllers/Admin/BatchUpdateStoresController.php
which has the following:
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
and I've added it to the routes.php file:
app/Http/routes.php|214| $api->put('stores', 'Admin\BatchUpdateStoresController@update');
app/Http/routes.php|215| $api->post('stores', 'Admin\BatchUpdateStoresController@upload');
also the relevant part in my composer file:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php",
"tests/Helpers/",
"tests/Traits/"
]
},
However, when I switch the branch to another git branch, and I try to run php artisan
, I get this error:
[ReflectionException] Class App\Http\Controllers\Admin\BatchUpdateStoresController does not exist
I find the above error interesting, as indeed that file doesn't exist (notice the actual file is app/Http/Controllers/Admin/BatchUpdateStoresController.php
, so app
!= App
, but aren't I already taking care of this in the psr-4
section of my composer.json file?
Ideas?
all the usual stuff including:
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
h2. udpdate
based on Edwards answer the following worked:
php artisan
will blow up, so then you already don't have access to some php artisan commands such as php artisan route:clear
php artisan
runsphp artisan route:clear
Try php artisan route:clear
if don't solve, put your complete exception.
since php artisan is already jammed, you should simply delete bootstrap/cache/routes.php
(ie in case you don't want to switch branches)
note: after you switch branches, you'll have to runphp artisan api:cache
or else it will complain that there are no routes