Javatpoint Logo
Javatpoint Logo

Laravel Application Structure

The application structure is the structure of folders, sub-folders, and files available in the project. Once the project is created in Laravel, the application structure generated as shown in the below screenshot:

Laravel Application Structure

Laravel's app directory

The app folder is one of the major folders in Laravel as most of the code is written in the app folder. The App folder contains the following sub-folders:

  • Console
  • Exceptions
  • Http
  • Providers
Laravel Application Structure

Console

Console folder contains the artisan commands required for Laravel. It contains the commands which are declared with the appropriate signature.

Exceptions

Exceptions folder contains the various exception handlers. It handles the exceptions thrown by the Laravel project. The Exceptions directory contains the methods that handle the exceptions.

The Exceptions directory contains the file handle.php that handles all the exceptions.

Http

The http folder is a sub-folder of the app folder. It has sub-folders such as controllers, middleware, and requests. Laravel follows the MVC architecture, so http includes controllers, views, and requests.

Where,

  • Middleware: It is a sub-folder of the http directory. It provides a filter mechanism and communication between request and response.
  • Requests: It is a sub-folder of http which includes all the requests of an application.

Providers

The Providers directory is used to contain all the service providers that are required to register events for core servers and provides configuration for Laravel application.

Laravel's bootstrap directory

The bootstrap directory holds the files that are required to bootstrap the Laravel application and to configure auto-loading. The bootstrap folder contains a sub-folder cache used for caching a web application. It also contains the file app.php that initializes the scripts required for bootstrap.

Laravel Application Structure

The above screen shows the structure of the bootstrap directory. It contains one folder, i.e., cache and two files, app.php and autoload.php.

Laravel's config directory

The config's directory contains the various configuration files required for the Laravel application. Various files are available inside the config's directory shown in the below screenshot, and each file performs their functionalities as per their names.

Laravel Application Structure

Laravel's Database directory

The database directory holds the database files. It contains sub-folders factories, migrations, and seeds. The structure of the database directory is shown below:

Laravel Application Structure

The database directory consists of three sub-folders:

  • Factories: The factories folder is used to generate a huge number of data records.
  • Migrations: The migrations folder is used to migrate the database in web application.
  • Seeds: The seeds folder contains the classes used to perform unit testing database.

Laravel's Public directory

The public directory is a root folder that contains the front controllers used for initializing the Laravel web application. Following are the sub-folders of a public directory:

  • .htaaccess: It is used for the server configuration.
  • Javascript and CSS: These files are considered as the main assets of a web application.
  • index.php: This file is used for initializing the web application.

The structure of the public directory is shown in the below screenshot:

Laravel Application Structure

Laravel's Resource directory

The resource directory holds the files used to enhance the web application. It contains the following sub-folders:

  • Assets: This folder contains the files such as LESS and SCSS used for styling the web application.
  • Lang: The lang folder provides configuration for localization or internationalization.
  • Views: The views folder contains html files used to interact with the end-users, and it also plays an important role in MVC architecture.

The structure of the Resource directory is shown below:

Laravel Application Structure

Laravel's Storage Directory

The storage directory contains those files which are required frequently when a Laravel project is running. It contains the following folders:

  • App: It contains the files which are called frequently.
  • Framework: It contains templates, filed based sessions, and file cache.
  • Logs: This folder tracks the exceptions and error logs.

The structure of the storage directory is shown in the below screenshot:

Laravel Application Structure

Laravel's Test directory

The test directory holds all the automated unit test cases. The naming convention of test classes is camel_case but follow the naming convention according to the functionality of a class.

Laravel's Vendor directory

The vendor directory contains the composer dependencies, for example, to install Laravel setup, the composer is required. The vendor folder contains all the composer dependencies.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA