laracon2017

  • 所有者: adamwathan/laracon2017
  • 平台:
  • 许可证:
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Cruddy by Design

During my talk at Laracon 2017, I shared some strategies I use to split large controllers into multiple small controllers.

The core idea is to try and stick to the 7 standard REST/CRUD actions in your controllers:

  • Index
  • Show
  • Create
  • Store
  • Edit
  • Update
  • Destroy

Using this convention as a "rule" is a good way to force yourself to keep your controllers from becoming bloated, and can often lead to learning interesting new things about your domain.

For the presentation, I put together a demo app called "CastHacker" that showcases podcasts about software development. It's not a "real" app by any means (lots of imaginary features, no tests, etc.); it's just enough code to demonstrate the concepts from the presentation. Feel free to clone it and play with it locally if you like though.

I've written up each refactoring I shared in the presentation as a detailed pull request:

  1. Give nested resources a dedicated controller

  2. Treat properties edited independently as separate resources

  3. Treat pivot models as their own resource

  4. Think of different states as different resources

主要指标

概览
名称与所有者adamwathan/laracon2017
主编程语言PHP
编程语言PHP (语言数: 3)
平台
许可证
所有者活动
创建于2017-08-02 19:04:15
推送于2018-02-08 18:45:52
最后一次提交2018-02-08 13:45:30
发布数0
用户参与
星数495
关注者数18
派生数81
提交数16
已启用问题?
问题数5
打开的问题数3
拉请求数5
打开的拉请求数0
关闭的拉请求数3
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?