ruslanashaari
2/17/2017 - 1:37 AM

Dry & Skinny Laravel Application

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