Laravel Folder and File Structure: A Complete Guide

- Andrés Cruz - ES En español

Video thumbnail

A Laravel project structure can vary quite a bit depending on your configuration and the packages you install. We are not just talking about environment tools like Laravel Sail; starting from Laravel 11, major changes in project organization have been introduced that are worth knowing from the beginning. Below, we review the main folders and files you will find in any Laravel project.

The app directory

The app directory is the heart of the application: almost all business code lives here and where we will spend most of our development time. It contains the main application classes organized into subfolders such as Http, Models, Console, and Exceptions, among others created according to project needs.

The bootstrap directory

The bootstrap directory contains the app.php file, which is responsible for bootstrapping the framework. The startup flow begins in public/index.php, which is the first file executed by the web server and in turn loads bootstrap/app.php to boot the entire application. Inside this directory, you will also find a cache subfolder with files automatically generated by the framework to optimize performance, such as route caching and compiled services. Under normal conditions, you don't need to modify anything here.

The config directory

The config directory centralizes all application configuration files. Here you will find files such as app.php, database.php, cors.php, mail.php, and many more, each responsible for a specific aspect of the system. Any third-party package you install can also publish its own configuration files to this directory using the php artisan vendor:publish command.

The database directory

The database directory houses everything related to the database: migrations (in database/migrations), which define and version the table schema; factories (in database/factories), used to generate test data; and seeders (in database/seeders), which allow populating the database with initial data. Optionally, you can also store an SQLite database file here if you prefer not to configure an external database engine during local development.

The lang directory

The lang directory houses all application language files. Starting from Laravel 11, this directory is no longer included by default; you must publish it manually when you need multi-language support by running:

$ php artisan lang:publish

Once published, you will find subfolders for each language (for example, lang/es and lang/en), each containing .php or .json files with the application's translatable strings.

The public directory

The public directory is the only directory that the web server (Apache, Nginx, etc.) should point to. It contains the index.php file, which serves as the entry point for all HTTP requests and configures Composer's autoloading. Additionally, assets that the browser can directly consume are stored here: images, compiled JavaScript files, CSS stylesheets, fonts, and any other static resources. In production, Vite compiles and publishes assets to this directory.

The resources directory

The resources directory contains uncompiled application resources. Here you will find Blade views in resources/views, as well as raw CSS and JavaScript files in resources/css and resources/js respectively. These files are processed by Vite during build time, and the output is published to the public directory. If you use Vue, React, or any other JavaScript framework, their components will also live here.

The routes directory

The routes directory contains all route definitions for the application. Starting from Laravel 11, the structure was simplified, and by default only two files are included:

  1. web.php: Contains routes for the web application, meaning those consumed from the browser. These routes are configured with session state, CSRF protection, and cookie encryption.
  2. console.php: Here you can define console commands using Artisan::command(), a lightweight alternative to creating full classes in app/Console/Commands.

Starting from Laravel 11, the following files are optional and must be published manually:

  1. api.php: Contains routes for building a REST API. These routes are stateless; requests are authenticated via tokens, typically with Laravel Sanctum. To publish it, run:
$ php artisan install:api

Upon executing this command, Laravel will automatically install Laravel Sanctum as a project dependency:

./composer.json has been updated
Running composer update laravel/sanctum
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking laravel/sanctum (v4.X)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Downloading laravel/sanctum (v4.X)
  - Installing laravel/sanctum (v4.X): Extracting archive
  1. channels.php: This is where you register event broadcasting channels supported by your application. To publish it, run:
$ php artisan install:broadcasting

The storage directory

The storage directory is the framework's internal storage space. Compiled Blade templates, file-based sessions, caches, application logs, and any other runtime-generated files are stored here. It is divided into three subfolders: storage/app for application-generated files, storage/framework for internal framework files, and storage/logs for activity logs. To make user-uploaded files accessible from the browser, a symbolic link is created with php artisan storage:link, pointing from public/storage to storage/app/public.

The tests directory

The tests directory contains automated tests for the project. By default, Laravel includes support for PHPUnit and comes preconfigured to work with Pest, a testing framework with a more expressive and modern syntax. Inside, you will find two subfolders: tests/Feature for integration tests simulating real HTTP requests, and tests/Unit for unit testing specific classes and methods.

The vendor directory

The vendor directory contains all project dependencies managed by Composer. Here, the Laravel framework itself is installed alongside any third-party package declared in composer.json. This directory should never be committed to the repository; it is excluded via .gitignore and regenerated in each environment by running composer install.

Main subfolders of app

As mentioned, the app directory is where we focus most of our development. Let's look at its most important subfolders:

The Http directory

The Http directory groups everything related to the HTTP entry layer. You will find controllers in app/Http/Controllers, middleware in app/Http/Middleware, and Form Requests in app/Http/Requests. The latter are dedicated form validation classes that keep controllers clean and focused on business logic.

The Models directory

The Models directory contains all model classes for Eloquent, Laravel's ORM. Each database table has a corresponding model that acts as an interface to interact with it: you can query, insert, update, and delete records using object-oriented syntax without writing raw SQL. Additionally, models allow defining table relationships (such as hasMany, belongsTo, belongsToMany), making work with related data exceptionally smooth.

The next natural step is to learn in detail how routes in Laravel work.

Get to know the folder and file structure of a Laravel project: what each directory does (app, bootstrap, config, database, public, resources, routes, storage, vendor).


Únete a la comunidad de desarrolladores que han decidido dejar de picar código y empezar a construir productos reales. Recibe mis mejores trucos de arquitectura cada semana:

I agree to receive announcements of interest about this Blog.