Directory Structure of Laravel

The image is showing the files and directories of laravel. It is automatically created when we create a project using a composer or laravel installer.

Let’s we overview these files and directories.

First we understand about files.

.env

This is an environment file where we put credentials (username password and other information) which will use in the project. Ex. Database username, password, database name, any third party creds like Mailgun, Redis, etc.

We can change the path of this file for more security purpose. Go to vendor\vlucas\phpdotenv\src\Loader and change it in the constructor.

.gitattribute

It just hint about git. Don’t think more about this file.

.gitignore

Here we put file name which will not commit in bitbucket or git repos.

artisan

When we run PHP artisan command in terminal or command prompt actually we trigger this file only. It runs The Artisan Application.

composer.json

This is the configuration file that specifies all dependencies or dependencies for development purpose.

composer.lock

It lock the version of dependencies. So, In future when we’ll install the dependency, Install same version.

package.json

This is related to frontend dependency. you may find the which frontend dev dependencies (with version) is installed. Ex.vue,jquery etc.

server.php

This file allows us to emulate Apache’s “mod_rewrite” functionality from the built-in PHP web server.

webpack.mix.js

It compiles scss or less or js files.

api.php

Here we can register API routes for our application.

channels.php

Here we may register all of the event broadcasting channels that our application supports.

console.php

Here we may define all of our Closure based console commands and run on terminal. ex. PHP artisan inspire or PHP artisan foobar etc.

web.php

we can register web routes for our application.

Ex. Route::get(‘/’,’RegisterController@index’); Route::post(‘/register’,’RegisterController@register’);

Directories

App Directory

The app directory contains the core code of your application.

Bootstrap Directory

The bootstrap directory contains the app.php file which bootstraps the framework.

Config Directory

The config directory, as the name implies, contains all of your application’s configuration files.

Database Directory

The database directory contains your database migrations, model factories, and seeds.

Public Directory

The public directory contains the index.php file, which is the entry point for all requests entering your application and configures autoloading. This directory also houses your assets such as images, JavaScript, and CSS.

Resources Directory

The resources directory contains your views as well as your raw, un-compiled assets such as LESS, SASS, or JavaScript. This directory also houses all of your language files.

Routes Directory

The routes directory contains all of the route definitions for your application.

Storage Directory

The storage directory contains your compiled Blade templates, file-based sessions, file caches, and other files generated by the framework.

Test Directory

This directory contain the test code of our project for testing purpose.

vendor Directory

This directory contains the core files of the composer so no need to worry about this and here we don’t create files/folders writes code in existing files.

Total Page Visits: 88 - Today Page Visits: 0