
Laravel is one of the most popular PHP frameworks, and one of the main reasons behind its popularity is its clean, well-organised directory structure.
If you understand how Laravel organises files and folders, developing, debugging, and scaling applications becomes much easier.
This article explains each Laravel directory in detail, why it exists, and how developers should use it in real projects.
Why Understanding Laravel’s Directory Structure Is Important
Before jumping into coding, it’s important to understand where things belong in Laravel.
A clear understanding helps you:
- Write clean and maintainable code
- Debug issues faster
- Scale applications confidently
- Follow Laravel best practices
- Collaborate easily with other developers
Laravel follows the MVC (Model–View–Controller) architecture, and its directory structure reflects that clearly.
Root Directory Overview
When you create a new Laravel project, you’ll see multiple folders and files at the root level.
Each one has a specific role and should be used correctly.
Let’s go through them one by one.
app/ – The Core Application Logic
The app The directory contains the main business logic of your Laravel application.
This is where most of your backend work happens.
Common Subdirectories Inside app/
Controllers
- Handle incoming HTTP requests
- Process user input
- Return responses (views or JSON)
Models
- Represent database tables
- Handle database queries and relationships
- Encapsulate business rules
Middleware
- Filter HTTP requests
- Handle authentication, authorisation, logging, etc.
Providers
- Register services into Laravel’s service container
- Bootstrap application components
Exceptions
- Handle custom exception logic
👉 In simple terms, the app The folder is the brain of your application.
bootstrap/ – Application Startup
The bootstrap. The directory is responsible for starting and initialising Laravel.
It contains:
- Application bootstrapping files
- Cached configuration and route files (for performance)
This directory is mostly managed by Laravel itself, and developers rarely need to modify it.
config/ – Configuration Files
The config The directory contains all configuration settings for your application.
Examples include:
- Application name and timezone
- Database configuration
- Mail and queue settings
- Cache and session configuration
Most values here are loaded from the .env file, making it easy to change settings per environment.
👉 This folder acts as the control panel of your Laravel application.
database/ – Database Management
The database The directory handles everything related to your database structure and data setup.
Key Subfolders
migrations
- Define database table structures
- Version-controlled schema changes
seeders
- Insert default or sample data
- Useful for development and testing
factories
- Generate fake data for testing
- Commonly used with seeders
👉 Think of this folder as the blueprint of your database.
public/ – Publicly Accessible Files
The public The directory is the only folder accessible from the browser.
It contains:
index.php(entry point of Laravel)- CSS, JavaScript, images
- Public uploads (if configured)
⚠️ For security reasons, all requests must point to the public folder.
This ensures:
- Application logic remains protected
- Sensitive files are not exposed
resources/ – Frontend and Views
The resources The directory holds everything related to the user interface.
Important Subfolders
views
- Blade template files
- HTML structure of your pages
css
- Stylesheets
- Tailwind or custom CSS files
js
- JavaScript logic
- Frontend interactions
lang
- Language and translation files
- Useful for multi-language applications
👉 This folder represents the visual layer of your application.
routes/ – URL Routing System
The routes A directory defines how URLs map to application logic.
Common Route Files
web.php
- Web routes
- Uses sessions, cookies, and CSRF protection
api.php
- API routes
- Stateless and JSON-based
console.php
- Artisan command routes
👉 This directory controls how users interact with your application through URLs.
storage/ – Logs, Cache, and Uploaded Files
The storage The directory stores runtime and temporary data.
Includes:
- Application logs
- Cached files
- Compiled views
- User uploads
This directory must have read and write permissions; Laravel will throw errors.
👉 Think of it as Laravel’s working memory.
tests/ – Automated Testing
The tests The directory contains test cases used for:
- Unit testing
- Feature testing
Testing ensures:
- Application stability
- Fewer bugs in production
- Confidence during refactoring
Even though beginners may ignore this initially, it’s essential for professional projects.
vendor/ – Dependencies
The vendor The directory contains:
- Laravel core files
- Third-party packages installed via Composer
⚠️ Never modify files inside this directory manually.
If something goes wrong here, simply reinstall dependencies using Composer.
Important Root Files Explained
.env – Environment Configuration
Stores sensitive and environment-specific values such as:
- Database credentials
- API keys
- App environment and debug mode
This file should never be committed to version control.
artisan – Command Line Tool
Laravel’s powerful CLI utility.
Used for:
- Creating controllers and models
- Running migrations
- Clearing cache
- Starting development server
composer.json
Defines:
- PHP dependencies
- Autoloading rules
- Project metadata
Laravel Directory Structure – Quick Summary Table
| Directory | Purpose |
|---|---|
| app | Application logic |
| routes | URL routing |
| resources | Views & frontend |
| database | Migrations & seeders |
| public | Public assets |
| storage | Logs & cache |
| config | App configuration |
| vendor | Dependencies |
Beginner Recommendation
If you are new to Laravel, focus first on:
approutesresources/viewsdatabase
Understanding these four directories will cover 80% of daily Laravel development.
Final Thoughts
Laravel’s directory structure is logical, scalable, and developer-friendly.
Once you understand where each piece belongs, building complex applications becomes simple and organised.
Mastering this structure is the first step toward becoming a confident Laravel developer.