Laravel Project Structure Guide
Complete Reference to Folders and Files in a Laravel Project
Table of Contents
- 1. Project Overview
- 2. app/ – Application Core
- 3. bootstrap/
- 4. config/
- 5. database/
- 6. public/
- 7. resources/
- 8. routes/
- 9. storage/
- 10. tests/
- 11. Other Important Files
1. Project Overview
Laravel follows a well-organized directory structure that separates different aspects of your application. This structure helps maintain clean, organized code and follows industry best practices.
my-laravel-project/ ├── app/ │ ├── Console/ │ ├── Exceptions/ │ ├── Http/ │ │ ├── Controllers/ │ │ ├── Middleware/ │ │ └── Requests/ │ ├── Models/ │ └── Providers/ ├── bootstrap/ ├── config/ ├── database/ ├── public/ ├── resources/ ├── routes/ ├── storage/ └── tests/
2. app/ – Application Core
The app/ directory contains the core code of your application.
Console/
Contains custom Artisan commands. You can create new commands using:
php artisan make:command SendEmails
Exceptions/
Contains the application’s exception handler and is where you can place custom exception classes.
Http/
Contains controllers, middleware, and form requests.
Controllers/
All your application’s controllers reside here. Create a new controller with:
php artisan make:controller UserController
Middleware/
Middleware provides a convenient mechanism for filtering HTTP requests. Create new middleware with:
php artisan make:middleware CheckAge
Requests/
Form request classes for validation. Create with:
php artisan make:request StoreUserRequest
Models/
Contains your Eloquent model classes. Create a new model with:
php artisan make:model User
Providers/
Service providers are the central place for Laravel application bootstrapping. Create with:
php artisan make:provider CustomServiceProvider
3. bootstrap/
Contains the app.php file which bootstraps the framework. The cache/ directory contains framework-generated files for performance optimization.
4. config/
Contains all your application’s configuration files. Important files include:
app.php– Core application settingsdatabase.php– Database configurationauth.php– Authentication configurationmail.php– Email settings
5. database/
Contains database migrations, seeders, and factories.
Migrations/
Database schema migrations. Create with:
php artisan make:migration create_users_table
Seeders/
Database seed classes. Create with:
php artisan make:seeder UsersTableSeeder
Factories/
Model factories for testing. Create with:
php artisan make:factory UserFactory
6. public/
The web server’s document root containing:
index.php– The application entry point- Assets (CSS, JavaScript, images)
7. resources/
Contains your views, raw assets (LESS, SASS, JS), and language files.
views/
Blade templates. Create views in appropriate subdirectories.
js/
JavaScript files (typically used with Laravel Mix).
lang/
Language files for localization.
8. routes/
Contains all route definitions:
web.php– For web routes (session state, CSRF protection)api.php– For API routes (rate limited)console.php– For Artisan command routeschannels.php– For event broadcasting channels
9. storage/
Contains:
app/– Storage for generated filesframework/– Framework-generated fileslogs/– Application log files
10. tests/
Contains PHPUnit test classes. Create with:
php artisan make:test UserTest
11. Other Important Files
.env– Environment configurationcomposer.json– PHP dependenciespackage.json– Frontend dependenciesartisan– Laravel command-line interfacewebpack.mix.js– Laravel Mix configuration
