Answer the question
In order to leave comments, you need to log in
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'
);
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question