無意間發現自己的專案有一個頁面更改不生效,然後製造bug發現laravel路由一直指向舊的控制器。
環境 linux centos
發現問題的過程
Effect為正常控制器補錄 Effect_back為舊的
使用find . -name "*.php" |xargs grep -i "Effect_back"發現了問題所在
./vendor/composer/autoload_classmap.php: 'App\\Http\\Controllers\\Effect\\ActivityController' => $baseDir . '/app/Http/Controllers/Effect_back/ActivityController.php',
./vendor/composer/autoload_classmap.php: 'App\\Http\\Controllers\\Effect\\FunnelController' => $baseDir . '/app/Http/Controllers/Effect_back/FunnelController.php',
./vendor/composer/autoload_classmap.php: 'App\\Http\\Controllers\\Effect\\SopController' => $baseDir . '/app/Http/Controllers/Effect_back/SopController.php',
./vendor/composer/autoload_static.php: 'App\\Http\\Controllers\\Effect\\ActivityController' => __DIR__ . '/../..' . '/app/Http/Controllers/Effect_back/ActivityController.php',
./vendor/composer/autoload_static.php: 'App\\Http\\Controllers\\Effect\\FunnelController' => __DIR__ . '/../..' . '/app/Http/Controllers/Effect_back/FunnelController.php',
./vendor/composer/autoload_static.php: 'App\\Http\\Controllers\\Effect\\SopController' => __DIR__ . '/../..' . '/app/Http/Controllers/Effect_back/SopController.php',
此刻就能發現問題出現在composer身上
解決方法
此問題應該是在你有新舊檔案時 執行過composer dump-autoload 所導致舊的檔案自動載入進來 並進行了快取
composer clear-cache
composer dump-autoload
如有錯誤請大佬指正 第一次寫
本作品採用《CC 協議》,轉載必須註明作者和本文連結