0

I have LoginController_old.php and LoginController.php

When I go into the 127.0.0.1/login

I find it runs to the LoginContrller_old.php

not obey the web.php route

Auth::routes();

I use php artisan route:list I see the route is right

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');

But why it always go to the wrong route...

I trid change the name to old_Logincontroller.php then shows the error message...

"include(/var/www/html/comefo/vendor/composer/../../app/Http/Controllers/Auth/LoginController_old.php): failed to open stream: No such file or directory"

I search the vendor/composer/autoload_static.php I find the error

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',

How come the question? why has the autoload_static.php to mix the route? And how I fix this and never use the autoload_static.php because it waste my whole day.....

fix1 use php artisan route:cache I got the error

   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.
robspin
  • 771
  • 3
  • 14
  • 33
  • 1
    `autoload_static.php` is generated automatically from your routes and namespaces. You need to run `composer dump-autoload ` to re generate `autoload_static.php`. Nothing more is needed – Leena Patel Oct 09 '18 at 06:54
  • 1
    There is no problem with Composer here, you are looking in the wrong direction. All classes in `app` folder must follow PSR-4 in order for autoload to work the way it's setup for Laravel. `LoginController_old.php` is not PSR-4 compliant. If you've setup all routes according to documentation then my bet is you are just redirected to another route. – d3jn Oct 09 '18 at 07:08

1 Answers1

1

It might be possible that, depending on your chosen environment Laravel has cached up your routes.

You can try out the following two commands in your CLI

php artisan cache:clear
php artisan route:cache

Reference: Laravel Docs Artisan Cache

After that the route cache should be rebuild. If this is not working for you, you can also try to refresh the composer cache.

composer dump-autoload 

Reference: Composer Dump Autoload Docs

You could also check out this post: How to clear Route Caching on server: Laravel 5.2.37

Please let me know if you got more problems. Hope this is helpful to you!

Tstar
  • 518
  • 5
  • 24
  • I try the "composer update" can fix the question But Can I avoid the error message again? Or when I need to use these command when I do what? – robspin Oct 09 '18 at 06:13
  • @robspin it is never good practice to just supress error messages. have you tried all the things i mentioned? – Tstar Oct 09 '18 at 06:20
  • I use artisn route:cache got the error message I have post in the post. – robspin Oct 09 '18 at 07:09
  • Maybe you have a broken url over in your routes.php. go and check all urls to be valid ! – Tstar Oct 09 '18 at 07:12