Laravel repository solution?

assume that data storage drivers can be switched through the configuration file, such as storing the data in mysql, and then changing the configuration file to redis.
currently my pseudo code is as follows:

1: create an interface

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind("App\Repositories\Interfaces\CategoryInterface",
            "App\Repositories\Implement\CategoryMysqlRepository");
    }
}

how to change the binding mode to achieve the above purpose. Thank you.

Mar.14,2021

dynamically bind by reading database drivers, such as

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        // key  database.driver  redis/mysql
        $dbDriver = ucfirst(config('database.driver')); 

        $this->app->bind('App\Repositories\Interfaces\CategoryInterface',
            "App\Repositories\Implement\Category{$dbDriver}Repository");
    }
Menu