Get your next remote job on LaraJobs.
1 contributor Edit on GitHub Laravel

3 crucial Laravel architecture best practices for 2023

Table of contents:

3 crucial Laravel architecture best practices for 2023

Introduction to architecturing Laravel projects

How should you organize your Laravel app to best serve your needs? Well, the good news is that you don’t have to worry about this since you are using a framework! Stick to the defaults unless you have good and objective reasons to do otherwise.

And yet, people can’t stop overthinking the architecture of their projects.

To me, it seems that the urge to deviate from the standard project structure often reveals a deeper issue - a fundamental inability to maintain organization. Whether you adhere to the Laravel architecture or significantly modify it, the outcome is likely to be disorganized.

Therefore, to address this problem, we will put ourselves in shoes that would fit almost any enterprise project.

Before we begin, though, let’s define what an “enterprise project” is in our context. Essentially, it’s a public facing project with lots of users that generates revenue, making it vital to continuously evolve by adapting to new technologies, business requirements, and market trends.

Here’s what is expected from the team of such projects:

  1. Easy collaboration.
  2. Maximize compatibility with third-party solutions that will help maintain the cost of development down.
  3. Keep the cost of onboarding low. To achieve this, new hires need to easily find their way around the codebase, which can make them somewhat productive even when they lack domain knowledge.

With these goals in mind, let’s dive into what I, and most of the experts from the community, think are the best architecture practices.

If you prefer a one-to-one call to show me your code and ask whatever question you might have, you can book a session, now.

Laravel architecture best practices

Keep the default folder structure

Using Laravel is meant to make your life easier, not harder.

  1. First, following conventions helps ensure that new hires can quickly find everything they need and start being productive as soon as possible. Laravel is a popular framework, and most developers will already be familiar with its default folder structure. By sticking to this, you help minimize the learning curve for new team members.
  2. Also, a profitable project is supposed to last for many years. People come and go. You will likely move on to something else. Why wouldn’t you make it easy for the ones who will take over?
  3. Additionally, by following the framework’s defaults, you ensure compatibility with many first and third-party packages. This can be crucial for maintaining development costs down and maximizing the use of available resources.

Organize by domain without breaking the folder structure

While it’s essential to keep the default folder structure, it’s also necessary to organize your code in a way that makes sense for your project. One way to do this is by organizing it by domain, without breaking the default folder structure.

This means that, for example, inside your Models folder, you could create a Blog folder. This way, when using the php artisan make:model Blog/Category command, the new file will be created at the right place.

This approach can also be used for controllers, middlewares, policies, and so on. Organizing your code the intended way will help you maintain a compatible, clean and intuitive codebase.

Don’t reach out for a package when Laravel already has a solution

Developers love discovering new ways of doing things, and it’s always tempting to experiment with new packages or approaches. This is fine for personal projects or when you are working alone, but it may not be ideal in a team setting.

When you hire Laravel developers, you are hiring them to expand and maintain your product using Laravel. It’s essential to remember this and stick to the built-in features of Laravel whenever possible.

For example, don’t use Data Transfer Objects (DTOs) instead of custom form requests unless there are good and objective reasons to do so. Using the built-in features of Laravel ensures that all developers on your team are working with the same set of tools and reduces the learning curve for new hires.

Don’t take my word for it, listen to the other experts

Matt Stauffer, who has a lot of experience building apps for enterprise as the CEO of Tighten, talks about how keeping things simple benefits big projects.

James Brooks is a core Laravel team member. He knows what working with a big team and a big codebase are. He also asked me to include it in this article, so there he is!

Sebastian Schlein is the co-founder of BeyondCo, a company deeply involved with Laravel, and he also thinks that you should stick to the framework’s defaults. This is a tweet from 2019 by the way.

Jason McCreary, from Laravel Shift, also showcases his favorite way of organizing Laravel projects. Looks familiar, don’t you think?

All that being said, at the end, results matter the most. Here’s a tweet from Taylor Otwell himself about keeping an open mind:

I can provide more guidance tailored to your codebase if you book a call with me.

Benjamin Crozat

Written by Benjamin Crozat

Indie hacker, blogger, and AI enthusiast building things with the TALL stack. 🔥

Follow me on:

Recommended articles

20+ Laravel best practices, tips and tricks to use in 2023 20+ Laravel best practices, tips and tricks to use in 2023

Learning a framework can be overwhelming, but time and execution will make you a master. Here are some best practices to help you toward your goal.

Modified on Oct 17, 2023

Laravel interview questions and answers for 2023 Laravel interview questions and answers for 2023

Nailing a Laravel job interview can be a daunting task, but with the right preparation and mindset, you can set yourself up for success.

Modified on Sep 19, 2023 Audio available

9 testing best practices for Laravel in 2023 9 testing best practices for Laravel in 2023

Are you familiar with testing? Good. Here are a bunch of best practices to help you level up even more!

Modified on Oct 27, 2023

Laravel 10: the upgrade guide from version 9 Laravel 10: the upgrade guide from version 9

I show you how to upgrade your Laravel 9 project to version 10 and help you decide whether the return on investment is worth it.

Modified on Nov 2, 2023

12 Laravel security best practices for 2023 12 Laravel security best practices for 2023

Secure your Laravel app: protect sensitive files, keep your packages and Laravel updated, use policies, validate input, and more.

Modified on Sep 5, 2023

Gold sponsors New

  • Wire Elements
    Beautiful handcrafted Livewire components.
    Check site
Your business here


If you buy from one of my partners below, I will be compensated at no cost to you. These are services I use or used, and 100% stand behind.

  • Scalable and reliable VPS hosting.
    Bonus: $200 of free credits
    Check site
  • The Google Analytics alternative without compromise.
    Free trial: 30 days
    Bonus: $10 off your first invoice
    Check site
  • Flare
    Track PHP and JavaScript errors in one place.
    Free trial: 10 days
    Check site
  • Keep track of your Google rankings.
    Free trial: 7 days
    Promo code: WELCOME30
    Check site
- / -