Laravel Folder Structure Explained
When you create a new project using Laravel the framework automatically generates a set of folders and files. This structure helps organize the application and keeps different parts of the project separated.
For beginners, the folder structure may look confusing at first. However, once you understand the purpose of the main directories, it becomes much easier to navigate and work with a Laravel project.
Below are some of the most important folders you will see inside a Laravel project.
Laravel Project Folder Hierarchy
A typical Laravel project structure looks something like this:
laravel-project/ │ ├── app/ │ ├── Http/ │ │ ├── Controllers/ │ │ └── Middleware/ │ ├── Models/ │ └── Providers/ │ ├── bootstrap/ │ └── cache/ │ ├── config/ │ ├── database/ │ ├── factories/ │ ├── migrations/ │ └── seeders/ │ ├── public/ │ └── index.php │ ├── resources/ │ ├── css/ │ ├── js/ │ └── views/ │ ├── routes/ │ ├── web.php │ └── api.php │ ├── storage/ │ ├── vendor/ │ ├── .env └── composer.json
app
The app/ folder contains the core application code. This is where most of your business logic will live.
Common files and directories inside this folder include:
- Models – Represent database tables and handle data operations
- Http/Controllers – Handle requests and control application logic
- Middleware – Filter and process incoming HTTP requests
- Providers – Register services and configure application components
In most projects, developers spend a lot of time working inside the app/ directory.
bootstrap
The bootstrap/ folder is responsible for starting the Laravel application. It contains files that initialize the framework and prepare it to handle incoming requests.
One important directory inside it is:
- cache – Stores compiled files that help improve performance.
Developers usually do not need to modify files in this folder frequently.
config
The config/ directory stores configuration files for the application. These files control how different parts of Laravel behave.
Examples include configuration for:
- Database connections
- Application settings
- Mail services
- Caching
- File storage
Most configuration values are linked with environment variables defined in the .env file.
database
The database/ folder contains files related to database structure and data management.
Important directories inside it include:
- migrations – Define the database table structure
- seeders – Insert sample or default data into the database
- factories – Generate fake data for testing
These tools help developers manage databases in a structured way.
public
The public/ folder is the entry point of the Laravel application. When a user accesses a Laravel website through a browser, the request is directed to the index.php file located in this directory.
This folder also stores publicly accessible assets such as:
- Images
- CSS files
- JavaScript files
Only the files inside the public/ directory should be accessible from the web.
resources
The resources/ folder contains frontend-related files used by the application.
Common directories inside this folder include:
- views – Blade template files used to render web pages
- css – Stylesheets
- js – JavaScript files
Developers create the user interface of their application inside the views/ directory.
routes
The routes/ folder defines how the application responds to different URLs.
The most commonly used file is:
- web.php – Defines routes for web pages
- api.php – Defines routes for API endpoints
Routing is one of the core concepts in Laravel, and these files control how users interact with the application.
storage
The storage/ folder is used for storing generated files and logs.
It includes directories for:
- Application logs
- Cached files
- Uploaded files
- Compiled templates
This folder helps Laravel manage temporary and runtime data safely.
vendor
The vendor/ directory contains all third-party packages installed through Composer. This includes the Laravel framework itself and other dependencies required by the application.
Developers should not modify files inside this folder because they are automatically managed by Composer.
Understanding the Overall Structure
Laravel's folder structure is designed to keep different parts of the application separate and organized. Backend logic, configuration files, frontend resources, and third-party packages are all placed in their own directories.
Once you become familiar with these folders, navigating a Laravel project becomes much easier, and you can quickly find the files you need while developing your application.