By default, the directory structure of Laravel is meant to meet the requirements for both large and small application development. But there is a provision to arrange it according to your needs. Laravel doesn't impose any restriction on locating your given class anywhere - providing the composer is free to load that class automatically. In this tutorial, you will learn about the two directory structures of Laravel. So, let us dig deep into it.
The Root Directory Structure of Laravel
This directory is one of the most important directories, inside which you will find some other subdirectories. These are:
Directory | Description |
---|---|
app | The app directory holds the base code for your Laravel application. |
bootstrap | The bootstrap directory contains all the bootstrapping scripts used for your application. |
config | The config directory holds all your project configuration files (.config). |
database | The database directory contains your database files. |
public | The public directory helps start your Laravel project and maintains other necessary files such as JavaScript, CSS, and images of your project. |
resources | The resources directory holds all the Sass files, language (localization) files, and templates (if any). |
routes | The routes directory contains all your definition files for routing, such as console.php, api.php, channels.php, etc. |
storage | The storage directory holds your session files, cache, compiled templates, and miscellaneous files generated by the framework. |
test | The test directory holds all your test cases. |
vendor | The vendor directory has all composer dependency files. |
The App Directory Structure of Laravel
This is another Laravel directory that holds other subdirectories for additional purposes. These are:
Directory | Description |
---|---|
Console | The Console directory contains all your project artisan commands. |
Events | The Events directory holds event files that your laravel application may pop up. Events are used for sending messages or signals to other parts of the laravel project that any action has occurred within the project. |
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. |
Jobs | The Jobs directory holds all lineup jobs in this directory. But it does not get created initially; instead, you need to type and run this artisan command:
|
Listeners | The Listeners directory holds all your project's handler classes for receiving and handling events. |
The Main directory holds all the emails sent through your Laravel project, and this directory needs to be created using the command:
| |
Notifications | The Notifications directory contains all your transactional notifications sent through your Laravel project, and this directory needs to be created using the command:
|
Policies | The policies directory holds different policies for your laravel project. |
Providers | The Providers directory is used to contain different service providers. |
Rules | The Rules directory holds all the different objects related to custom validation rules, and this directory needs to be created using the command:
|