php - Laravel warehouse mode solved!
高洛峰
高洛峰 2017-06-30 09:54:09
0
2
770
  • First create an interface file TestInterface.php file.

  • Create two Repository files to specifically implement the TestInterface interface.

  • Bind

  • is added to providers in the app.php file.

  • Controller writing

  • Question: Refer to the writing method in my controller. If this is the case, then there is not much meaning in writing the interface. Even if there is no interface file, I can use two Repository# Methods in ##. Please give me some advice on the correct way to open the controller. If I use the interface in the controller like this, how to use it, thank you guys!

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
漂亮男人

Personally, I feel that the warehouse model mentioned in various laravel tutorials on the Internet is only suitable for encapsulating some complex query operations, and is useless for others. The complete warehouse model needs to cooperate with the domain model. In laravel, the model cannot play the role of the domain model. Moreover, there is basically no decoupling operation between the warehouse and Laravel's own ORM, so it is of little significance to define an interface for the model.

Of course, these are just personal understandings, and discussion is welcome. Still need to learn relevant knowledge about domain-driven design

Ty80

Not going to discuss this warehouse pattern, the interface should be injected into the controller constructor part of your code

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!