LARAVEL Tutorial


Laravel 6 Application Directory Structure


Any framework application has its own directory structure. Laravel also has its own directory structure. This directory structure tells here how to do the work in this framework or what file should be kept. So that developers and programmers have no problems in working with these frameworks and developing web applications.

If you are learning or working with laravel framework. You must know about the laravel application directory structure. It will contain many folders in it. You can see the below in Image

You can see above the larva application directory structure image. Each of the folders and files in the above image and overview serves a specific function for the overall functioning of the larval structure. The purpose of each of these folders is to display below, but first, let's take a look at their overview once:

Laravel Application Directory Structure

Let's see the overview of laravel application directory structure below:

  • app directory
  • bootstrap directory
  • config directory
  • database directory
  • public directory
  • resources directory
  • routes directory
  • storage directory
  • tests directory
  • vendor directory

app directory

This directory is the main folder of the laravel framework. It contains all the main code files of our web application like Controllers, Models, Middlewares, Exceptions, Console, Providers, Custom Artisan Commands etc. This directory further contains many sub-directories like you can see below:

DIRECTORY Name Uses of directory
Console This directory holds Artisan commands. You can create a custom artisan command using the php artisan make:command command.
Exceptions This directory holds the exception handling files. Here also, you can create your own specific exceptions handing the file to be thrown by our application.
Http This directory holds controllers, middleware, and kernal.php. Almost all of the backend to handle requests entering our application will be placed here.
Providers This directory holds all the service providers for the application. Service providers bootstrap our application by making services available to us by registering them.
Broadcasting By default, this directory is not there.But You can create using php artisan make:channel command. It holds all the broadcast channel classes for our web application to broadcast your events.
Events By default, this directory is not there. But You can create using php artisan make:event command. This directory contains event classes that can be used to give signals to other parts of the application or vice-versa.
Jobs By default, this directory is not there. But You can create using the php artisan make:job command. This directory contains lineup jobs for our application.
Listeners By default, this directory is not there. But You can create using the php artisan make:listener command. This directory holds the classes that handle our events.
Mail By default, this directory is not there. But You can create using the php artisan make:mail command. This directory holds all of our classes that represent emails sent by the web application.
Notifications By default, this directory is not there. But You can create using the php artisan make:notification command. This directory holds all of the “transactional” notifications that are sent by our application.
Policies By default, this directory is not there. But You can create using the php artisan make:policy command. This directory holds the authorization policy classes which are used to determine if a user can access or change specific data or not.
Rules

By default, this directory is not there. But You can create using the php artisan make:rule command. This directory holds the self-created validation rule objects which are used to encapsulate complicated validation logic in a simple object.

bootstrap directory

This directory holds app.php file and cache directory which is used to store framework generated files for performance optimization.

config directory

The config directory holds all the application configuration files like database, mail, session, services file etc.

database directory

This directory holds database migrations, model factories and seeds files.

public directory

This directory holds important file name index.php file, which is the entry point and handles all requests recieved by the application and configures autoloading too. Apart from this, this directory also holds scripts (JavaScript and CSS) and images.

resources directory

This directory holds the frontend template files of the web application and also holds language (localization) files, sass files.

routes directory

This directory holds all the routing files of the your web application web.php, console.php, api.php, channels.php etc.

storage directory

This directory holds the session files, cache files, compiled Blade templates, and other files generated by framework.

tests directory

This directory holds all of your automated tests which are required to ensure that the application is working as per expectations or not.

vendor directory

This directory holds all the dependencies downloaded through Composer or Package files.