E
E
Eugene2015-02-18 20:54:01
Laravel
Eugene, 2015-02-18 20:54:01

How to dynamically assign binds in Laravel?

I write binds for interfaces (this is for the IUserRepo interface declaration to create the UserRepo class laravel.com/docs/5.0/container )

# AppServiceProvider.php
public function register() {
        $this->app->bind(
            'App\Repo\IUserRepo',
            'App\Repo\UserRepo'
        );
        $this->app->bind(
            'App\Repo\IMessageRepo',
            'App\Repo\MessageRepo'
        );
}

Does anyone know if this can be dynamically bound somehow? And that bothered to prescribe it for each essence.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Brezhnev, 2015-02-18
@Nc_Soft

Dynamically out of the box in any way. You can automatically look in the folder, sort through all the files and make a map, but this is the case if all the names of the interfaces and their implementations can be adjusted to one template

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question