How organize big projects in Laravel?


  • Introduction
  • What’s HMVC?
  • Advantages of using HMVC?
  • What’s wrong with the MVC pattern?
  • Let’s know how we can use the HMVC pattern in Laravel!
  • Pros
  • Cons
  • Best Packages that generate modules and implement that approach
  • Conclusion


Everyone when beginning a new project starts to ask himself/herself the following question?

  • How can I make organized the project well to be easy for me or for any other developer easy to understand for example if you’re looking for a file in a big project, you want to be easy to find that file, right?

We have many approaches and design patterns that make the project clean but in this article, I will talk about HMVC (the Hierarchical-model-view-controller) pattern which makes your application modular.

What’s HMVC?

The HMVC pattern extends the MVC pattern and is a solution to overcome scalability problems apparent within large MVC applications.

An HMVC application operates using a collection of MVC entities where each MVC entity can execute without the presence of any other. Ideally, each entity should never load models or libraries of other entities.

Advantages of using HMVC?

  • HMVC supports the reuse of code
  • HMVC allows easy distribution of MVC entities stored in a single directory.
  • HMVC reduces dependencies and allows to easily extend applications while retaining ease of maintenance.
  • Testing is easier because the system is divided to a large extend into independent parts.

What’s wrong with the MVC pattern?

The Model-View-Controller (MVC) paradigm remains one of the more enduring patterns. However, the traditional MVC scope falls short when it comes to the control of GUI elements (widgets). MVC does not handle the complexities of data management, event management, and application flows.

HMVC provides a powerful yet easy-to-understand layered design methodology for developing a complete presentation layer.

Let’s know how we can use the HMVC pattern in Laravel!

Let’s assume we have an accounting project that has (Banking — Sale— Transaction), the question now is how we can organize the project using HMVC! let’s divide these three parts into MVC components so you can have each of them separately developed but used as one!

Example from a real accounting project

Each module has its own (routes - middleware - controllers- etc..), and it’s help you to make your project more organized.


  • Modularization: reduction of dependencies between the disparate parts of the application.
  • More organized: having a folder for each of the relevant triads makes for a lighter workload.
  • Reusability: by the nature of the design it is easy to reuse nearly every piece of code.
  • Extendibility: this makes the application more extensible without sacrificing ease of maintenance.


Create More Folders But the solution of it in my opinion that we will remove unused folders.

Best Packages that generate modules and implement that approach

we have many packages with Laravel that generate modules but I will share in this article my own package (Laragine) and other packages that I used in many projects.

Laravel Modules

  • Is a Laravel package that was created to manage your large Laravel app using modules.
  • This package just structures your project (Modules) and doesn’t provide any implementation.


  • is a Laravel package that was created to manage your large Laravel app using modules also but here’s a difference, this package implements all API CRUD operations with unit tests, the package generates (Controller — Model — Factories — Migrations — unit tests — etc..), all you need to do to just add your API route in your route folder and everything (APIs CRUD operations) will work magically sounds interesting, right!
  • check this video to know more.
  • I wrote a series of blogs about it on the dev website
  • Check the documentation


Basically, the HMVC pattern is just an extension of MVC. An HMVC application includes one or more MVC sub-applications. so anything MVC can do, HMVC can do too. Now, it depends on whether you need the flexibility and scalability that HMVC offers.

Let’s connect on LinkedIn, Twitter




Software engineer, Problem solver, Geek.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to: Pimp my Powerline in PowerShell

MonkeyLeague Development Update #2


What is the AWS CLI?

Apache Calcite Code Reading Part 2

CSS Grid, maintaining aspect ratio and managing overflow

Tutorial for Artists on how to use a Neural Network — Part 2

Alter Your Stratos Tokens project’s Configuration to Supercharge Your Design Tokens

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Software engineer, Problem solver, Geek.

More from Medium

How to find the slowest query in your Laravel application

Forest Admin vs. Laravel Nova

5 mistakes that makes you a noob in PHP

Top 10 Github packages for your Laravel app in 2022