Laravel folder structure

The Laravel folder structure has been created to make developers easilyorganize and manage the code. Here's a more detailed breakdown of the
most important directoriesin it along with their
purposes

laravel folder structure

Laravel Folder Structure Explained:-

1. App

It holds the core application logic and is based on the MVC (Model-View-Controller) architecture.
Console/: Holds custom Artisan commands.
Exceptions/: Manages application exceptions and error handling.

Http/:
Controllers/: Holds controllers that carry out the application logic.
Middleware/: Contains middleware 
to filter HTTP requests.
Requests/: 
Deals with form validation and request sanitization.
Models/: 
Contains Eloquent ORM models for interaction with the database.
Custom Directories: You can 
add custom directories for services or repositories whenever you need to.

App

2. Bootstrap

Contains files for initializing the application.
app.php: It loads the framework and bootstraps the application.
cache/: 
Framework-generated cache files for optimal performance.

Bootstrap



3. Config

It contains configuration files for various parts of the application, like app.php, database.php, mail.php, etc.Easily modify settings like timezone, database 
credentials, and caching options.

Config


4. Database

Manages resources related to the database.
migrations/: Database migration files to create or alter the schema of the database.
factories/: 
Model factories for creating test data
seeders/: Adds test or seed data in the database

Database

5. Public

index.php application entry point Files included here are public and fall under CSS, JavaScript images, and compiled assets.

Public

6. Resources

Raw resources on views, frontend assets, and translations
views/: Blade Templates for UI rendering
lang: Translation files for locale.
js/ and css/: Raw frontend assets (if using Laravel Mix).

Resources

7. Routes

It contains route definitions for the application.
web.php: Routes for web-based requests (uses sessions and cookies).
api.php: Routes for APIs (stateless).
console.php: Console commands for Artisan.
channels.php: Defines broadcast channels for real-time events.

Routes

8. Storage

It handles file storage, logs, and cache.
app/: 
It stores application files.
framework/: Framework-generated files like sessions and cache.
logs/: 
It contains application log files.

Storage


9. Tests

It contains test cases for unit and feature testing.
Feature/: Tests 
bigger application features like HTTP routes.
Unit/: Tests 
classes and methods one by one.

Test

10. Vendor

This folder holds Composer dependencies and third-party packages. Never touch 
it directly.

Vendor

11. Artisan

Command-line interface for tasks such as migrations, seeding, and caching.

Artisan


12. Env

Contains configurations based on the environment like database credentials, API

keys, and application settings. It is excluded from the version control due to security. 

ENV




3 Comments

Post a Comment

Previous Post Next Post