Laravel 对于修改控制器不生效
问题引入
无意间发现自己的项目有一个页面更改不生效,然后制造 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
如有错误请大佬指正 第一次写。
No Comments