Using dependency injection over laravel facades

后端 未结 6 1315
鱼传尺愫
鱼传尺愫 2021-01-30 16:48

I have read a number of sources that hint that laravel facade\'s ultimately exist for convenience and that these classes should instead be injected to allow loose coupling. Even

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 17:00

    I love the laravel due to its beautiful architecture.Now as from my approach i wouldnt inject all the facades in to the controller method only why? Injecting Redirect facades only in controller wrong practices as it might need in other. And mainly the things that are mostly used should be declared for all while for those who uses some or only then its best practice to inject them via method as when you declare at top it will hamper in your memory optimization as well as the speed of your code. Hope this would help

提交回复
热议问题