The application structure in Laravel is the structure of directories, sub-directories, and files included in a project. Once we create a project in Laravel, we get an overview of the application structure as shown in the image here.
The analysis of directories and files, along with their functions are as follows −
The app directory contains the base code for your Laravel application. It contains events, exceptions, and middleware declarations. It holds other sub-directories for additional purposes.
- Console - The Console directory contains all your project artisan commands.
- Exceptions - The Exceptions directory holds your laravel project's exception handling files, which handle all the exceptions thrown by your Laravel project.
- Http - The Http directory holds different filters, requests, and controllers.
- Providers - This directory includes all the service providers required to register events for core servers and configure a Laravel application.
This directory encloses all the application bootstrap scripts. It contains a sub-directory namely cache, which includes all the files associated with caching a web application. You can also find the file app.php, which initializes the scripts necessary for bootstrap.
The config directory holds all your project configuration files (.config).
The database directory holds your database files.
It includes three sub-directories as given below −
- seeds − This contains the classes used for the unit testing database.
- migrations− This folder helps in queries for migrating the database used in the web application.
- factories − This folder is used to generate a large number of data records.
It is the root directory that helps in initializing the Laravel application. It includes the following files and directories −
- .htaccess − This file gives the server configuration.
- index.php − This file is required for the initialization of a web application.
The resources directory contains all the Sass files, language (localization) files, and templates (if any).
The routes directory contains all your definition files for routing, such as console.php, api.php, channels.php, etc.
The storage directory contains your session files, cache, compiled templates as well as miscellaneous files generated by the framework.
The test directory contains all your test cases.
The vendor directory contains all composer dependency files.