Skip to content

Instantly share code, notes, and snippets.

@Sherlockboy
Created December 26, 2025 14:47
Show Gist options
  • Select an option

  • Save Sherlockboy/f39dc33bcd8a273ead7e8ea47d824fb1 to your computer and use it in GitHub Desktop.

Select an option

Save Sherlockboy/f39dc33bcd8a273ead7e8ea47d824fb1 to your computer and use it in GitHub Desktop.
Laravel Project Structure Guide

Opinionated project structure for Laravel

Main concepts

  • APIs should follow REST style
  • Controllers should follow CRUDy or Invokable style
    • CRUDy controllers should use Service classes
    • Invokable controllers should use Action classes
  • Complex queries should be moved to Query classes to be used inside Service or Action classes
  • Controllers should talk to Service/Action classes through Data Objects (DTO)
  • Request classes should map input to DTOs
  • Rules above must be monitored by CI pipelines using PestPHP Architecture Tests

Project strucutre

  • App/Http/Controllers/{Group}
    • {Group}CrudController (index, show, store, update, destroy)
    • {Group}ListExportController (__invoke)
  • App/Http/Requests/{Group}
  • App/Actions/{Group}
  • App/DTOs/{Group}
  • App/Queries/{Group}
  • App/Services/{Group}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment