为什么 Laravel 网站在 web.php 中没有转到正确的路径? autoload_static.php 是什么?
why Laravel web site not go to the right route in web.php? what is autoload_static.php?
我有 LoginController_old.php 和 LoginController.php
当我进入 127.0.0.1/login
我发现它运行到 LoginContrller_old.php
不遵守web.php路线
Auth::routes();
我用phpartisanroute:list
我看路线是对的
Route::get('login', 'App\Http\Controllers\Auth\LoginController@showLoginForm');
Route::post('login', 'App\Http\Controllers\Auth\LoginController@login');
Route::get('logout', 'App\Http\Controllers\Auth\LoginController@logout');
可是为什么总是走错路...
我尝试将名称更改为 old_Logincontroller.php
然后显示错误信息...
"include(/var/www/html/comefo/vendor/composer/../../app/Http/Controllers/Auth/LoginController_old.php): failed to open stream: No such file or directory"
我搜索vendor/composer/autoload_static.php
我发现错误
public static $classMap = array (
'App\Console\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
'App\Events\News' => __DIR__ . '/../..' . '/app/Events/News.php',
'App\Events\Queue_number' => __DIR__ . '/../..' . '/app/Events/Queue_number.php',
'App\Exceptions\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
'App\Http\Controllers\Auth\ForgotPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
'App\Http\Controllers\Auth\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController old.php',
怎么来的问题?
为什么会有autoload_static.php混合路由?以及我如何解决这个问题并且从不使用 autoload_static.php 因为它浪费了我一整天.....
修正1
利用
php artisan route:cache
我收到错误
LogicException : Unable to prepare route [api/user] for serialization. Uses Closure.
at /var/www/html/comefo/vendor/laravel/framework/src/Illuminate/Routing/Route.php:880
876| */
877| public function prepareForSerialization()
878| {
879| if ($this->action['uses'] instanceof Closure) {
> 880| throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
881| }
882|
883| $this->compileRoute();
884|
Exception trace:
1 Illuminate\Routing\Route::prepareForSerialization()
/var/www/html/comefo/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php:62
2 Illuminate\Foundation\Console\RouteCacheCommand::handle()
/var/www/html/comefo/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
Please use the argument -v to see more details.
根据您选择的环境,Laravel 可能已经缓存了您的路线。
您可以在 CLI 中尝试以下两个命令
php artisan cache:clear
php artisan route:cache
之后应该重建路由缓存。
如果这对您不起作用,您还可以尝试刷新作曲家缓存。
composer dump-autoload
参考:Composer Dump Autoload Docs
您还可以查看此 post:
如果您有更多问题,请告诉我。
希望对您有所帮助!
我有 LoginController_old.php 和 LoginController.php
当我进入 127.0.0.1/login
我发现它运行到 LoginContrller_old.php
不遵守web.php路线
Auth::routes();
我用phpartisanroute:list 我看路线是对的
Route::get('login', 'App\Http\Controllers\Auth\LoginController@showLoginForm');
Route::post('login', 'App\Http\Controllers\Auth\LoginController@login');
Route::get('logout', 'App\Http\Controllers\Auth\LoginController@logout');
可是为什么总是走错路...
我尝试将名称更改为 old_Logincontroller.php 然后显示错误信息...
"include(/var/www/html/comefo/vendor/composer/../../app/Http/Controllers/Auth/LoginController_old.php): failed to open stream: No such file or directory"
我搜索vendor/composer/autoload_static.php 我发现错误
public static $classMap = array (
'App\Console\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
'App\Events\News' => __DIR__ . '/../..' . '/app/Events/News.php',
'App\Events\Queue_number' => __DIR__ . '/../..' . '/app/Events/Queue_number.php',
'App\Exceptions\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
'App\Http\Controllers\Auth\ForgotPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
'App\Http\Controllers\Auth\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController old.php',
怎么来的问题? 为什么会有autoload_static.php混合路由?以及我如何解决这个问题并且从不使用 autoload_static.php 因为它浪费了我一整天.....
修正1 利用 php artisan route:cache 我收到错误
LogicException : Unable to prepare route [api/user] for serialization. Uses Closure.
at /var/www/html/comefo/vendor/laravel/framework/src/Illuminate/Routing/Route.php:880
876| */
877| public function prepareForSerialization()
878| {
879| if ($this->action['uses'] instanceof Closure) {
> 880| throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
881| }
882|
883| $this->compileRoute();
884|
Exception trace:
1 Illuminate\Routing\Route::prepareForSerialization()
/var/www/html/comefo/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php:62
2 Illuminate\Foundation\Console\RouteCacheCommand::handle()
/var/www/html/comefo/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
Please use the argument -v to see more details.
根据您选择的环境,Laravel 可能已经缓存了您的路线。
您可以在 CLI 中尝试以下两个命令
php artisan cache:clear
php artisan route:cache
之后应该重建路由缓存。 如果这对您不起作用,您还可以尝试刷新作曲家缓存。
composer dump-autoload
参考:Composer Dump Autoload Docs
您还可以查看此 post:
如果您有更多问题,请告诉我。 希望对您有所帮助!