did you run composer dump after deleting files?
How to remove unused files from old versions after upgrading Laravel?
I've upgraded my Laravel API from 5.8 to 9.52 (progressively through every version) using Laravel Shift. This was done months ago and everything works fine, but today I've tried to remove some controller files from the old versions (that I don't use in my code) and I'm getting error 500.
I have a Vue/Laravel SPA and use Sanctum cookie-based session authentication. All user login/registration is done on files inside \Controllers root.
For example, in app/Http/Controllers/Auth there are several files that I believe belong to Laravel < 6*:
ConfirmPasswordController.php
ResetPasswordController.php
ForgotPasswordController.php
RegisterController.php
And some other files. If I remove ConfirmPasswordController.php I get error 500 when I try to login the user and the following error in the logs:
local.ERROR: include(C:\Users\username\repos\my-app\vendor\composer/../../app/Http/Controllers/Auth/ConfirmPasswordController.php): Failed to open stream: No such file or directory {"exception":"[object] (ErrorException(code: 0): include(C:\Users\username\repos\my-app\vendor\composer/../../app/Http/Controllers/Auth/ConfirmPasswordController.php): Failed to open stream: No such file or directory at C:\Users\username\repos\my-app\vendor\composer\ClassLoader.php:582)
[stacktrace]
0 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(270): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'include(C:\\User...', 'C:\\Users\\username\\...', 582)
1 C:\Users\username\repos\my-app\vendor\composer\ClassLoader.php(582): Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}(2, 'include(C:\\User...', 'C:\\Users\\username\\...', 582)
2 C:\Users\username\repos\my-app\vendor\composer\ClassLoader.php(582): include('C:\\Users\\username\\...')
3 C:\Users\username\repos\my-app\vendor\composer\ClassLoader.php(433): Composer\Autoload\{closure}('C:\\Users\\username\\...')
4 [internal function]: Composer\Autoload\ClassLoader->loadClass('App\\Http\\Contro...')
5 C:\Users\username\repos\my-app\vendor\laravel\ui\src\AuthRouteMethods.php(43): class_exists('App\\Http\\Contro...')
6 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Routing\Router.php(501): Illuminate\Routing\Router->Laravel\Ui\{closure}(Object(Illuminate\Routing\Router))
7 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Routing\Router.php(457): Illuminate\Routing\Router->loadRoutes(Object(Closure))
8 C:\Users\username\repos\my-app\vendor\laravel\ui\src\AuthRouteMethods.php(18): Illuminate\Routing\Router->group(Array, Object(Closure))
9 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Macroable\Traits\Macroable.php(124): Illuminate\Routing\Router->Laravel\Ui\{closure}(Array)
10 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Routing\Router.php(1462): Illuminate\Routing\Router->macroCall('auth', Array)
11 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Support\Facades\Auth.php(96): Illuminate\Routing\Router->__call('auth', Array)
12 C:\Users\username\repos\my-app\routes\web.php(21): Illuminate\Support\Facades\Auth::routes()
13 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Routing\RouteFileRegistrar.php(35): require('C:\\Users\\username\\...')
14 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Routing\Router.php(503): Illuminate\Routing\RouteFileRegistrar->register('C:\\Users\\username\\...')
15 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Routing\Router.php(457): Illuminate\Routing\Router->loadRoutes('C:\\Users\\username\\...')
16 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Routing\RouteRegistrar.php(192): Illuminate\Routing\Router->group(Array, 'C:\\Users\\username\\...')
17 C:\Users\username\repos\my-app\app\Providers\RouteServiceProvider.php(37): Illuminate\Routing\RouteRegistrar->group('C:\\Users\\username\\...')
18 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): App\Providers\RouteServiceProvider->App\Providers\{closure}()
19 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Container\Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
20 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(81): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
21 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure), Object(Closure))
22 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Container\Container.php(661): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Object(Closure), Array, NULL)
23 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Support\Providers\RouteServiceProvider.php(120): Illuminate\Container\Container->call(Object(Closure))
24 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Support\Providers\RouteServiceProvider.php(45): Illuminate\Foundation\Support\Providers\RouteServiceProvider->loadRoutes()
25 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): Illuminate\Foundation\Support\Providers\RouteServiceProvider->Illuminate\Foundation\Support\Providers\{closure}()
26 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Container\Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
27 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(81): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
28 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure), Object(Closure))
29 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Container\Container.php(661): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Object(Closure), Array, NULL)
30 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Support\ServiceProvider.php(119): Illuminate\Container\Container->call(Object(Closure))
31 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(932): Illuminate\Support\ServiceProvider->callBootedCallbacks()
32 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(910): Illuminate\Foundation\Application->bootProvider(Object(App\Providers\RouteServiceProvider))
33 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(App\Providers\RouteServiceProvider), 29)
34 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(909): array_walk(Array, Object(Closure))
35 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\BootProviders.php(17): Illuminate\Foundation\Application->boot()
36 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(242): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
37 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(176): Illuminate\Foundation\Application->bootstrapWith(Array)
38 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(160): Illuminate\Foundation\Http\Kernel->bootstrap()
39 C:\Users\username\repos\my-app\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(134): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
40 C:\Users\username\repos\my-app\public\index.php(51): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
41 {main}
"}
I found that ConfirmPasswordController is referenced in vendor/laravel/ui/src/AuthRouteMethods.php, example:
<?php
namespace Laravel\Ui;
class AuthRouteMethods
{
/**
* Register the typical confirm password routes for an application.
*
* @return callable
*/
public function confirmPassword()
{
return function () {
$this->get('password/confirm', 'Auth\ConfirmPasswordController@showConfirmForm')->name('password.confirm');
$this->post('password/confirm', 'Auth\ConfirmPasswordController@confirm');
};
}
}
ConfirmPasswordController.php:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ConfirmsPasswords;
class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/
use ConfirmsPasswords;
/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}
It has a reference to class Illuminate\Foundation\Auth\ConfirmsPasswords that does not exist in Laravel 9.
Why are these files being referenced in vendor if they are not included in Laravel 9? How can I remove these unusable files?
Please or to participate in this conversation.