Laravel follows a well-organized directory structure that is designed to provide a clear separation for development tasks more efficient.
Laravel project File structure:
app: This directory is the core of your application and contains the following subdirectories:
- Console: Artisan commands and command-related classes.
- Exceptions: Custom exception handler classes.
- Http:
- Controllers: Controllers handle user requests and contain methods for processing those requests.
- Middleware: Middleware classes process HTTP requests before they reach the controller.
- Requests: Form request classes for handling validation logic.
bootstrap: Contains files needed to bootstrap the Laravel application and load Composer dependencies.
config: Configuration files for various aspects of the Laravel application, such as database connections, mail settings, and more.
database: Database-related files, including migrations, seeds, and factories.
- migrations: Database migration files for defining and modifying database tables.
- seeds: Database seed files for populating tables with test data.
- factories: Factory classes for generating model instances with fake data.
public: The entry point for your web application (index.php) and publicly accessible assets (CSS, JavaScript, images).
resources: Contains views, language files, and assets used by your application.
- views: Blade templates for generating HTML responses.
- lang: Language files for localization.
- assets: Uncompiled assets such as CSS and JavaScript.
routes: Contains route definitions for your application.
- web.php: Web routes for handling HTTP requests.
- api.php: API routes for handling API requests.
- console.php: Artisan console command routes.
storage: Contains files generated by your application, such as logs, cache, and compiled views.
- app: Application-generated files (e.g., logs).
- framework: Framework-generated files (e.g., cache, sessions).
- logs: Log files.
tests: PHPUnit test cases for your application.
vendor: Where Composer installs dependencies.
.env: Environment-specific configuration settings for your application.
artisan: Artisan is a command-line utility for interacting with your Laravel application. It provides commands for tasks such as database migrations, testing, and more.