Laravel 12 directory structure explained
When you install Laravel 12 and open the project for the first time, you will see a lot of folders and files. For beginners this can look scary but the truth is that the Laravel folder structure follows a very clean and logical project structure. Once you understand what each folder does and what kind of files it contains, you will see why Laravel is considered one of the most developer friendly frameworks.
In this guide, we will go through the Laravel 12 directory structure in detail. I will explain the purpose of each folder what important files are inside and how you will interact with them while building real time projects.
Why the Laravel Folder Structure Matters
The Laravel directory structure is not random. It follows the MVC architecture (Model-View-Controller), which means code is separated into logical parts. This structure helps keep projects clean, avoids duplication, and makes teamwork much easier.
If you are moving from raw PHP to a framework, learning the Laravel project folder structure is the first big step toward writing professional and maintainable code.
Top Level Structure of a Laravel 12 Project
Now let’s break these down one by one.
app/ – Core Application Logic
The app/ folder is where most of your Laravel application logic lives. This is the most important part of the project. Inside you will find several important subfolders:
-
Http/ → This holds controllers, middleware, and request classes. This is also known as the Laravel controller folder.
-
Models/ → Every database table usually has a model. For example,
User.phprepresents the users table. Models in Laravel 12 use Eloquent ORM. -
Console/ → Custom Artisan commands are stored here.
-
Exceptions/ → All exception handling and error reporting logic is stored here.
Most of your day-to-day work in Laravel will be inside app/Http/ and app/Models/.
bootstrap/ – Bootstrapping the Framework
The Laravel bootstrap folder is all about getting Laravel ready to run. It loads the framework files and sets up caching for better performance.
-
The most important file is
app.phpwhich bootstraps the application. -
There is also a
cache/subfolder (often called the Laravel cache folder) where Laravel stores performance-related files.
config/ – Application Configuration
Every setting in your application is stored in the config/ folder. For example:
-
app.php→ Contains application name, timezone, locale, and encryption key. -
database.php→ Manages database connections. -
mail.php→ Stores mail server details. -
queue.php→ Defines how jobs and queues are handled.
In Laravel 12 the config files are well organized, making it easy to change behavior without touching the core code.
database/ – Managing Databases
Instead of writing raw SQL every time, Laravel gives you migrations, factories, and seeders inside the database/ folder.
-
migrations/→ Version control for your database schema. -
factories/→ Generate fake data for testing. -
seeders/→ Preload the database with default data.
This structured approach makes Laravel database management easier and professional.
public/ – Entry Point for the Browser
The Laravel public folder is the only folder directly accessible from the browser. The file index.php acts as the front controller that passes requests to Laravel.
If you add CSS, JavaScript, or image files here, they can be accessed directly in the browser. In real projects, though, most assets are processed by Vite or Mix (via the resources/ folder) and then published here.
👉 Many developers also configure an htaccess file for Laravel public folder or for the root folder, to manage URL rewrites and security.
resources/ – Views and Frontend Assets
The Laravel resources folder is for everything related to your application’s front end.
-
views/→ Blade templates (likewelcome.blade.php). -
js/→ JavaScript files, often compiled with Vite. -
css/→ Stylesheets. -
lang/→ Language files for multilingual apps.
If you are adding Bootstrap, Tailwind, Vue, or React in Laravel 12, you’ll work inside this folder.
Sometimes developers refer to this as the Laravel assets folder because it contains all raw frontend resources before compilation.
routes/ – Defining Application Routes
Laravel routes live in the routes/ folder:
-
web.php→ Routes for web pages. -
api.php→ Routes for APIs (this forms the Laravel API folder structure). -
console.php→ Artisan command routes. -
channels.php→ Event broadcasting routes.
storage/ – Logs and Cached Data
The Laravel storage folder holds all generated files that Laravel needs while running. It includes cached views, sessions, logs, and temporary files.
-
app/→ Stores user files generated by the app. -
framework/→ Contains cache, compiled views, and session data. -
logs/→ Application logs (useful for debugging).
Make sure the storage folder is writable, otherwise Laravel will throw errors.
tests/ – Writing Automated Tests
The tests/ folder includes both unit tests and feature tests. Laravel uses PHPUnit or Pest.
-
Feature/→ Tests larger features like routes or APIs. -
Unit/→ Tests small, isolated pieces of code.
vendor/ – Composer Dependencies
The Laravel vendor folder contains all third-party packages installed via Composer. It includes the Laravel framework itself plus any extra packages you’ve added.
If the Laravel vendor folder is missing, you can restore it by running:
This will install all dependencies defined in composer.json.
Other Important Files
-
artisan → The Artisan CLI tool.
-
composer.json → Defines PHP dependencies.
-
.env → Environment file for sensitive details like database credentials.
-
package.json → Node.js dependencies for frontend assets.
Conclusion
The Laravel 12 directory structure explained above shows how every folder plays a unique role. The app/ folder manages logic, the resources/ folder handles views and assets, the routes/ folder defines how users interact, and the database/ folder manages schema changes.
Folders like config/, storage/, tests/, and the Laravel vendor folder make your application professional, scalable, and reliable.
Once you know where everything belongs, you’ll not only work faster but also feel more confident moving from small personal projects to large-scale Laravel applications.
FAQs About Laravel Folder Structure
Q1. What is the use of Laravel bootstrap folder?
Baically It initializes the framework, loads the core files and manages caching through its cache/ subfolder.
Q2. What if my Laravel vendor folder is missing?
In this situation, Simply run composer install in your project root. This will regenerate the vendor folder in Laravel with all dependencies.
Q3. What is the Laravel storage folder used for?
It contains logs, cache, sessions, and uploaded files.
Q4. What is the Laravel services folder?
By default, Laravel does not include a services/ folder but developers often create one inside app/ to store custom service classes and website logic.
