In this post, we’ll explore Laravel’s default folder and file structure.
This structure is designed to keep your application’s logic, configuration, and resources well organized.
- The core of your application.
- Contains main application logic such as Models, Controllers, Middleware, etc.
- Important subfolders:
Http/→ Controllers, Middleware, and Requests.Models/→ Eloquent models for database interaction.Console/→ Custom Artisan commands.Providers/→ Service providers.
- Contains the files needed to bootstrap Laravel.
app.phpinitializes the application.- The
cache/folder stores cached routes and configuration files.
- Holds all configuration files for the project.
- Examples:
app.php,database.php,mail.php, etc. - Values from
.envare loaded here.
- Database-related files:
migrations/→ Create or modify database tables.factories/→ Generate test data.seeders/→ Insert initial data.
- The only directory accessible from the web.
- Contains:
index.php→ The entry point of the application.- Static files (CSS, JS, images).
- Contains raw resources for the application:
views/→ Blade templates.lang/→ Language files.css/,js/→ Front-end source files.
- Route definitions:
web.php→ Web routes (with sessions & cookies).api.php→ API routes (stateless).console.php→ Artisan command routes.channels.php→ Broadcast channels.
- Stores files generated by the application:
app/→ Uploaded files.framework/→ Cache, sessions, and compiled templates.logs/→ Application logs.
- Unit and Feature test files.
vendor/→ Composer dependencies..env→ Environment configuration.artisan→ Laravel CLI tool.composer.json→ Composer package list.package.json→ JavaScript dependencies.
Laravel’s organized directory structure helps developers manage their applications efficiently.
Familiarity with this structure will improve your development workflow and code maintenance.