laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 31 forks source link

Service Container | Contextual Binding of the Methods #2651

Open michael-rubel opened 3 years ago

michael-rubel commented 3 years ago

Hello!

It is an interesting concept to be able to control applications using the method binding. But currently, it is limited to use container calls. Why can't we use explicit contextual method binding outside of the constructor to be able to bind the implementation of one method to another without refactoring the app to use those calls?

@taylorotwell mentioned it is a bit complicated (see https://github.com/laravel/docs/pull/4798) even with calls. I think this would be very powerful if we had to maintain an application with a huge codebase and poor dependency management, Maybe there are some pitfalls that explain why it is still not implemented even in 2021 (requests of this functionality were at Laravel 5+)?