Skip to content

Instantly share code, notes, and snippets.

@tashirka1
Forked from nasrulhazim/dry_n_skinny.md
Created April 19, 2017 18:34
Show Gist options
  • Save tashirka1/459ef56ebea76c37b751c9f42579e41c to your computer and use it in GitHub Desktop.
Save tashirka1/459ef56ebea76c37b751c9f42579e41c to your computer and use it in GitHub Desktop.
Dry & Skinny Laravel Application

Dry & Skinny

  1. Fat Model & Skinny Controller

  2. Bus / Job Pattern

    • Command Bus > Jobs
      • A task take a small unit of work
      • NOT return a value
    • Further reading: CRUD & CQRS
    • Reusable, Skinny Controller as more reusable codes move to Job
    • Then use in Job Queue
    • Why Jobs?
      • Better response to end user
      • Heavy job can be delayed
    • Don't forget to Log
  3. Event / Listener

    • Some event happened, multiple listeners to the event
  4. Middleware

    • Authentication & Authorization always in middleware
  5. Mutators / Transformers

    • Format a model presentation
    • Controller don't need to play with formatting
    • Helps in defining API
    • Fractal by PHPLeague
  6. Specifications

    • return true or false
    • and() / or()
    • chaining
    • usually in call in controller
  7. Takeaways

    • offload things from controllers
    • refactor repeated code
    • read Laravel docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment