The error you're encountering is due to the MigrationRepositoryInterface not being properly bound in the service container. This can happen if the migration service provider is not registered correctly or if there are changes in the way Laravel handles migrations in the new version.
Here are the steps to resolve this issue:
-
Check Service Providers: Ensure that the
MigrationServiceProvideris registered in yourconfig/app.phpfile. This is usually done automatically, but it's good to verify.'providers' => [ // Other service providers... Illuminate\Database\MigrationServiceProvider::class, ], -
Update FreshCommand: Since you are extending the
FreshCommand, make sure you are importing the correct classes and namespaces. Also, ensure that the parent constructor is called properly.<?php namespace App\Console\Commands; use Illuminate\Database\Console\Migrations\FreshCommand as BaseFreshCommand; use Illuminate\Database\Migrations\Migrator; use Illuminate\Contracts\Container\Container; class FreshCommand extends BaseFreshCommand { /** * Create a new command instance. * * @param \Illuminate\Database\Migrations\Migrator $migrator * @param \Illuminate\Contracts\Container\Container $container * @return void */ public function __construct(Migrator $migrator, Container $container) { parent::__construct($migrator, $container); } /** * Drop all the database tables. Override base command for Mongo compatibility. * * @param string $database * @return void */ protected function dropAllTables(string $database): void { $this->laravel['db']->connection($database) ->getMongoDb() ->drop(); } } -
Clear Cache: Sometimes, cached configurations can cause issues. Clear the cache using the following commands:
php artisan config:clear php artisan cache:clear php artisan config:cache -
Composer Autoload: Regenerate the autoload files to ensure all classes are properly loaded.
composer dump-autoload -
Check Dependencies: Ensure that all your dependencies are up to date and compatible with Laravel 11. You can do this by running:
composer update
By following these steps, you should be able to resolve the BindingResolutionException related to the MigrationRepositoryInterface. If the issue persists, double-check the Laravel upgrade guide for any additional changes that might affect your setup.