Hacker News new | past | comments | ask | show | jobs | submit login

Laravel isn't an MVC framework. I often see people make this point and it puzzles me because even the creator of Laravel argues that it's not MVC.

Laravel has a "Model" abstraction, but its models are Active Record objects, i.e. database row proxies. The M in MVC is not supposed to be in 1:1 correspondence with your database tables. Laravel's Model class is poorly named.

The closest Laravel would come to being MVC would be by adding your business logic to service classes and adding them to Laravel's service container - an approach that the Laravel documentation mentions as a possibility but doesn't make a big deal of. Indeed, the documentation largely encourages the use of controllers to contain business logic.




Sounds as if you prefer the Microsoft take on MVC, where they introduced the "UI Model" as an additional component.

(Real) Model -> fetch -> UI Model -> build -> View

          ^

          |

          v

          build/modify 

          ^

          |

          v

          Controller
The UI Model serves as a simplified version of the "real" model that can also use the data structures/objects used by the technology used in the View.

In "original" MVC (outside of the use of this term in webdev), the "M" in MVC absolutely did refer to a 1:1 correspondence with the data at the core of the application. This works too, but when using various UI toolkits, adding the UI Model can make things feel a bit more natural.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: