Laravel Project Structure
β± Estimated reading time: 2 min
Laravel follows the ModelβViewβController (MVC) architecture and provides a well-organized directory structure that helps developers build clean, scalable, and maintainable applications. Below is a detailed explanation of the main folders and files in a Laravel project.
Root Directory
The root directory contains core configuration files and folders:
-
artisan β Command-line interface used to perform tasks like migrations, caching, and code generation.
-
composer.json / composer.lock β Define project dependencies and versions.
-
package.json β Manages frontend dependencies.
-
.env β Stores environment-specific configuration.
-
.gitignore β Specifies files and folders ignored by Git.
1. app/ Directory
This is the core of the application logic.
-
Http/
-
Controllers/ β Handle HTTP requests and responses.
-
Middleware/ β Filter requests (authentication, security).
-
-
Models/ β Represent database tables and handle data logic.
-
Providers/ β Register services and bindings.
2. bootstrap/ Directory
-
app.php β Initializes the Laravel framework.
-
cache/ β Stores cached configuration and routes.
3. config/ Directory
Contains all application configuration files such as:
-
app.php β Application settings
-
database.php β Database configuration
-
mail.php β Mail server settings
-
cache.php β Cache configuration
These files are connected to values in the .env file.
4. database/ Directory
Handles database-related files:
-
migrations/ β Define database table structures
-
seeders/ β Insert test or default data
-
factories/ β Generate fake data for testing
5. public/ Directory
This is the web root of the application.
-
index.php β Entry point for all HTTP requests
-
css/, js/, images/ β Public assets
6. resources/ Directory
Contains frontend and UI-related files:
-
views/ β Blade templates (HTML views)
-
lang/ β Language translation files
-
css/ and js/ β Frontend assets (processed by Vite)
7. routes/ Directory
Defines application routes:
-
web.php β Web routes (sessions, cookies)
-
api.php β API routes (stateless)
-
console.php β Artisan commands
-
channels.php β Event broadcasting channels
8. storage/ Directory
Stores generated and temporary files:
-
app/ β User-uploaded files
-
framework/ β Cache, sessions, compiled views
-
logs/ β Application logs
9. tests/ Directory
Contains automated tests:
-
Feature/ β Test application features
-
Unit/ β Test individual components
10. vendor/ Directory
Contains third-party libraries installed via Composer.
This folder is automatically generated and should not be edited manually.
Conclusion
The Laravel project structure is designed to promote clean code, reusability, and scalability. Understanding this structure helps developers navigate projects efficiently and follow best practices while building robust web applications.
Register Now
Share this Post
β Back to Tutorials