laracon2017

  • Owner: adamwathan/laracon2017
  • Platform:
  • License::
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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

Main metrics

Overview
Name With Owneradamwathan/laracon2017
Primary LanguagePHP
Program languagePHP (Language Count: 3)
Platform
License:
所有者活动
Created At2017-08-02 19:04:15
Pushed At2018-02-08 18:45:52
Last Commit At2018-02-08 13:45:30
Release Count0
用户参与
Stargazers Count495
Watchers Count18
Fork Count81
Commits Count16
Has Issues Enabled
Issues Count5
Issue Open Count3
Pull Requests Count5
Pull Requests Open Count0
Pull Requests Close Count3
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private