This content originally appeared on DEV Community and was authored by Harsh Mishra
Complete Laravel Project Directory Structure: MVC Architecture
Introduction to Laravel and Its Role in MVC Architecture
Laravel is one of the most popular PHP frameworks in the world of web development. Known for its elegant syntax and developer-friendly features, Laravel aims to make common web development tasks, like authentication, routing, sessions, and caching, much easier and more intuitive. Created by Taylor Otwell, Laravel has evolved into a full-fledged MVC (Model-View-Controller) framework, making it the go-to choice for modern web applications.
What is MVC Architecture?
The MVC (Model-View-Controller) architecture is a design pattern that separates the application logic into three interconnected components:
- Model: Represents the data and business logic of the application.
- View: Handles the display and presentation of the data.
- Controller: Acts as an intermediary between the Model and the View, handling user input and interactions.
Laravel follows this pattern to ensure that the application is clean, organized, and maintainable.
In this article, we will explore the complete directory structure of a Laravel project, specifically focusing on the MVC architecture and how each part contributes to the development process. By looking at the latest Laravel 11 directory structure, you'll be able to understand how Laravel enforces separation of concerns and keeps your codebase easy to scale and maintain.
Laravel 11 Directory Structure Overview
A standard Laravel project comes with a pre-defined structure that supports an MVC workflow, organized in a way that facilitates easy management of both backend and frontend logic. Below is the comprehensive directory structure of Laravel 11, broken down with explanations of the core directories and files you will encounter in a typical Laravel application.
π laravel-advanced-project/
βββ π app/
β βββ π Console/
β β βββ Kernel.php
β βββ π Events/
β β βββ PostCreated.php
β β βββ UserRegistered.php
β βββ π Exceptions/
β β βββ Handler.php
β βββ π Http/
β β βββ π Controllers/
β β β βββ π API/
β β β β βββ PostController.php
β β β β βββ UserController.php
β β β βββ π Web/
β β β β βββ HomeController.php
β β β β βββ ProfileController.php
β β βββ π Middleware/
β β β βββ Authenticate.php
β β β βββ RedirectIfAuthenticated.php
β β βββ π Requests/
β β β βββ UserRequest.php
β β β βββ PostRequest.php
β βββ π Models/
β β βββ User.php
β β βββ Post.php
β β βββ Comment.php
β βββ π Notifications/
β β βββ NewCommentNotification.php
β βββ π Policies/
β β βββ PostPolicy.php
β β βββ CommentPolicy.php
β βββ π Providers/
β β βββ AppServiceProvider.php
β β βββ AuthServiceProvider.php
β β βββ EventServiceProvider.php
β βββ π Services/
β β βββ UserService.php
β β βββ PostService.php
β βββ π Traits/
β β βββ ApiResponse.php
βββ π bootstrap/
β βββ app.php
βββ π config/
β βββ app.php
β βββ auth.php
β βββ database.php
βββ π database/
β βββ π factories/
β β βββ UserFactory.php
β β βββ PostFactory.php
β βββ π migrations/
β β βββ 2024_01_01_000000_create_users_table.php
β β βββ 2024_01_01_000001_create_posts_table.php
β β βββ 2024_01_01_000002_create_comments_table.php
β βββ π seeders/
β β βββ DatabaseSeeder.php
β β βββ UserSeeder.php
β β βββ PostSeeder.php
βββ π lang/
β βββ π en/
β β βββ auth.php
β β βββ validation.php
βββ π public/
β βββ π css/
β β βββ app.css
β βββ π js/
β β βββ app.js
β βββ π images/
β βββ index.php
βββ π resources/
β βββ π views/
β β βββ π layouts/
β β β βββ app.blade.php
β β βββ π users/
β β β βββ index.blade.php
β β β βββ show.blade.php
β β βββ π posts/
β β β βββ index.blade.php
β β β βββ show.blade.php
β βββ π js/
β β βββ app.js
β βββ π sass/
β β βββ app.scss
βββ π routes/
β βββ api.php
β βββ web.php
βββ π storage/
β βββ π app/
β β βββ uploads/
β βββ π logs/
β β βββ laravel.log
βββ π tests/
β βββ π Feature/
β β βββ UserTest.php
β β βββ PostTest.php
β βββ π Unit/
β β βββ UserServiceTest.php
β β βββ PostServiceTest.php
βββ .env
βββ .gitignore
βββ artisan
βββ composer.json
βββ package.json
βββ phpunit.xml
βββ README.md
βββ webpack.mix.js
Directory Breakdown
1. app/
β The Application Directory
The app/
directory is the heart of the application, where most of the business logic is placed. It contains several subdirectories that help in organizing the application components:
Console/
: Contains console commands. TheKernel.php
file defines the application's command schedule.Events/
: Houses event classes likePostCreated.php
andUserRegistered.php
, which are triggered during specific actions in the application.Exceptions/
: This directory manages exceptions in your app. TheHandler.php
file is used for handling exceptions globally.-
Http/
: Contains HTTP-specific files like controllers, middleware, requests, and more.-
Controllers/
: Divided into subdirectories likeAPI/
andWeb/
for handling API requests and web views respectively. -
Middleware/
: Handles HTTP request filtering. For example,Authenticate.php
checks whether the user is authenticated. -
Requests/
: Contains form request validation classes (e.g.,UserRequest.php
,PostRequest.php
).
-
Models/
: Contains the application's model classes (e.g.,User.php
,Post.php
,Comment.php
). These models are responsible for interacting with the database.Notifications/
: Contains notification classes, likeNewCommentNotification.php
, that notify users about various events.Policies/
: Contains policy classes (e.g.,PostPolicy.php
) that manage authorization logic for models.Providers/
: This directory contains service providers, which are used for bootstrapping various parts of the application. Common examples includeAppServiceProvider.php
andAuthServiceProvider.php
.Services/
: Custom service classes (e.g.,UserService.php
,PostService.php
) that are responsible for encapsulating specific application logic.Traits/
: Contains reusable code snippets that can be included in models, services, or other classes.
2. bootstrap/
β Bootstrapping the Application
The bootstrap/
directory is used to configure the application, load configuration files, and set up the initial environment. The app.php
file is where the Laravel application is bootstrapped.
3. config/
β Configuration Files
The config/
directory holds various configuration files such as app.php
(application settings), auth.php
(authentication settings), and database.php
(database configuration).
4. database/
β Database-Related Files
This directory contains everything related to database migrations, factories, and seeders:
-
factories/
: Used for creating fake data for testing. -
migrations/
: Houses migration files that define database schema changes. -
seeders/
: Contains seeder classes, which populate the database with initial data.
5. public/
β Public Assets
This is the only directory exposed to the web. It contains assets like CSS, JavaScript files, and images. The index.php
file is also here, which is the entry point for all requests.
6. resources/
β Views, Assets, and Language Files
Contains views, assets, and language files:
views/
: Contains Blade templates, which are used to render views. Thelayouts/app.blade.php
is the main layout file.js/
andsass/
: These directories store front-end assets like JavaScript and CSS.
7. routes/
β Defining Routes
Contains all route definitions for the application. The web.php
file handles web routes, while api.php
defines routes for APIs.
8. storage/
β Files, Logs, and Cache
Contains application-generated files, logs, and cache files. The uploads/
directory stores files uploaded by users, while logs/
contains Laravel's log files.
9. tests/
β Testing
This directory holds all tests for the application:
-
Feature/
: Tests for features that involve multiple components working together (e.g.,UserTest.php
,PostTest.php
). -
Unit/
: Unit tests for smaller components (e.g.,UserServiceTest.php
,PostServiceTest.php
).
10. Root Files
-
.env
: Contains environment-specific settings like database credentials. -
.gitignore
: Specifies files to be ignored by Git. -
artisan
: The Laravel command-line interface (CLI) file. -
composer.json
: Defines dependencies and configurations for Composer. -
phpunit.xml
: PHPUnit configuration for running tests. -
webpack.mix.js
: Configuration for asset compilation using Laravel Mix.
This breakdown of the Laravel 11 directory structure provides a comprehensive look at how everything is organized, ensuring you can develop clean, scalable, and maintainable applications. From handling requests in the controllers to working with the models and database, the structure follows the principles of MVC architecture, making it easier to manage complex applications.
π Complete Laravel Directory Structure (All Possible Directories at Any Level and Depth)
Each directory is followed by a brief explanation of its purpose.
πΉ 1. Core Laravel Application Directories (/app
)
These directories contain the application's core logic.
1οΈβ£ /app
β Main application logic (Models, Controllers, Middleware, Services, etc.).
2οΈβ£ /app/Console
β Custom Artisan commands and CLI-related functionality.
3οΈβ£ /app/Console/Commands
β Subdirectory for custom Artisan commands.
4οΈβ£ /app/Events
β Event classes for Laravel's event system.
5οΈβ£ /app/Exceptions
β Custom exception handling for the application.
6οΈβ£ /app/Http
β Houses controllers, middleware, and request classes.
7οΈβ£ /app/Http/Controllers
β Controller classes that handle HTTP requests.
8οΈβ£ /app/Http/Controllers/API
β API controllers for RESTful endpoints.
9οΈβ£ /app/Http/Controllers/Web
β Web controllers for handling browser-based requests.
π /app/Http/Middleware
β Middleware that filters HTTP requests.
1οΈβ£1οΈβ£ /app/Http/Requests
β Custom form request validation classes.
1οΈβ£2οΈβ£ /app/Models
β Eloquent ORM models interacting with the database.
1οΈβ£3οΈβ£ /app/Notifications
β Notification classes for emails, SMS, etc.
1οΈβ£4οΈβ£ /app/Observers
β Model observers that listen for model events.
1οΈβ£5οΈβ£ /app/Policies
β Authorization policies for defining user access control.
1οΈβ£6οΈβ£ /app/Providers
β Service providers for bootstrapping application services.
1οΈβ£7οΈβ£ /app/Services
β Custom service classes to handle business logic.
1οΈβ£8οΈβ£ /app/Traits
β PHP traits for code reusability.
1οΈβ£9οΈβ£ /app/Rules
β Custom validation rules for form requests.
2οΈβ£0οΈβ£ /app/Casts
β Custom attribute casting classes for Eloquent models.
πΉ 2. Laravel Bootstrapping (/bootstrap
)
Contains files that handle the bootstrapping process.
2οΈβ£1οΈβ£ /bootstrap
β Bootstraps the Laravel framework.
2οΈβ£2οΈβ£ /bootstrap/cache
β Stores cached configuration, services, and routes.
πΉ 3. Laravel Configuration (/config
)
Holds configuration files.
2οΈβ£3οΈβ£ /config
β Contains various Laravel configuration files.
2οΈβ£4οΈβ£ /config/auth.php
β Authentication settings.
2οΈβ£5οΈβ£ /config/cache.php
β Caching configuration.
2οΈβ£6οΈβ£ /config/database.php
β Database connection settings.
2οΈβ£7οΈβ£ /config/mail.php
β Email service configuration.
2οΈβ£8οΈβ£ /config/queue.php
β Queue settings.
2οΈβ£9οΈβ£ /config/services.php
β External API and service integrations.
πΉ 4. Laravel Database Directory (/database
)
Manages migrations, factories, and seeds.
3οΈβ£0οΈβ£ /database
β Contains all database-related files.
3οΈβ£1οΈβ£ /database/factories
β Model factory classes for test data.
3οΈβ£2οΈβ£ /database/migrations
β Migration files that manage database schema changes.
3οΈβ£3οΈβ£ /database/seeders
β Seeder classes to populate database tables.
3οΈβ£4οΈβ£ /database/sql
β Raw SQL dump files for database backup or restore.
πΉ 5. Localization & Language Files (/lang
)
3οΈβ£5οΈβ£ /lang
β Stores language translation files.
3οΈβ£6οΈβ£ /lang/en
β English translation files.
3οΈβ£7οΈβ£ /lang/fr
β French translation files.
3οΈβ£8οΈβ£ /lang/es
β Spanish translation files.
πΉ 6. Public Assets & Entry Point (/public
)
3οΈβ£9οΈβ£ /public
β Publicly accessible files like images, CSS, JS, and the entry index.php
.
4οΈβ£0οΈβ£ /public/css
β CSS stylesheets.
4οΈβ£1οΈβ£ /public/js
β JavaScript files.
4οΈβ£2οΈβ£ /public/images
β Static images.
4οΈβ£3οΈβ£ /public/fonts
β Font files.
4οΈβ£4οΈβ£ /public/storage
β Public storage linked to /storage/app/public
.
πΉ 7. Frontend & Views (/resources
)
4οΈβ£5οΈβ£ /resources
β Contains Blade views, JS, and CSS.
4οΈβ£6οΈβ£ /resources/views
β Blade template files for frontend rendering.
4οΈβ£7οΈβ£ /resources/css
β CSS files.
4οΈβ£8οΈβ£ /resources/js
β JavaScript files for frontend behavior.
4οΈβ£9οΈβ£ /resources/sass
β SASS/SCSS files for styling.
πΉ 8. Routing (/routes
)
5οΈβ£0οΈβ£ /routes
β Defines routes for web, API, and console.
5οΈβ£1οΈβ£ /routes/web.php
β Web routes (frontend).
5οΈβ£2οΈβ£ /routes/api.php
β API routes (RESTful).
5οΈβ£3οΈβ£ /routes/console.php
β Custom Artisan commands.
5οΈβ£4οΈβ£ /routes/channels.php
β Routes for event broadcasting.
πΉ 9. Laravel Storage (/storage
)
Stores logs, caches, and user uploads.
5οΈβ£5οΈβ£ /storage
β Stores logs, cache, and uploaded files.
5οΈβ£6οΈβ£ /storage/app
β Application-specific files (backups, uploads).
5οΈβ£7οΈβ£ /storage/app/public
β Publicly accessible storage files.
5οΈβ£8οΈβ£ /storage/framework
β Contains framework-generated files.
5οΈβ£9οΈβ£ /storage/framework/cache
β Caching data.
6οΈβ£0οΈβ£ /storage/framework/sessions
β Stores user session data.
6οΈβ£1οΈβ£ /storage/framework/views
β Compiled Blade templates for fast rendering.
6οΈβ£2οΈβ£ /storage/logs
β Log files for debugging.
πΉ 10. Testing (/tests
)
6οΈβ£3οΈβ£ /tests
β Unit and feature tests for the application.
6οΈβ£4οΈβ£ /tests/Feature
β Feature tests for app functionalities.
6οΈβ£5οΈβ£ /tests/Unit
β Unit tests for isolated components.
πΉ 11. Composer & Node Dependencies
6οΈβ£6οΈβ£ /vendor
β Contains all Composer dependencies.
π Conclusion
This is the most exhaustive list of all possible directories in a Laravel project. Some directories are always present, while others appear based on optional features, third-party packages, or specific configurations.
Understanding these directories helps you master Laravel and makes development more structured and maintainable. π
This content originally appeared on DEV Community and was authored by Harsh Mishra

Harsh Mishra | Sciencx (2025-03-10T16:31:23+00:00) Laravel Project Directory Structure: MVC Architecture. Retrieved from https://www.scien.cx/2025/03/10/laravel-project-directory-structure-mvc-architecture/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.