Home  >  Article  >  Backend Development  >  Laravel中使用Repository层必要吗?

Laravel中使用Repository层必要吗?

WBOY
WBOYOriginal
2016-06-06 20:16:461671browse

Laravel中使用Repository层必要吗?
有人说很多开源项目都用,
有人说作者说不用,所以从laravel5开始就删除了Repository文件夹,就在控制器中完成就好。
github上还专门有个名字叫l5-repository的包。
大家说说。

回复内容:

Laravel中使用Repository层必要吗?
有人说很多开源项目都用,
有人说作者说不用,所以从laravel5开始就删除了Repository文件夹,就在控制器中完成就好。
github上还专门有个名字叫l5-repository的包。
大家说说。

这得看项目而定,小型项目或者各模块相互独立的项目可以不用Repository层,模块业务复杂又相互交错的项目则需要。

我觉得跟ThinkPHP的Logic层有点像,试想下,当控制层多个类的方法都需要调用到相同的一段业务逻辑的时候,你会把这段业务逻辑放哪里,这时Repository就起作用了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn