Skip to content

Instantly share code, notes, and snippets.

@nasrulhazim
Created February 17, 2017 01:37
Show Gist options
  • Save nasrulhazim/3af25050ad7c9b8ff953c28b7ee91be9 to your computer and use it in GitHub Desktop.
Save nasrulhazim/3af25050ad7c9b8ff953c28b7ee91be9 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