How to create First Laravel Project Tutorial

Laravel Installation

Now, we’ll set up Laravel framework on PHP environment machine. We will build new laravel project from Composer. First we need to install composer within the local environment. Click here to get the reference – How to install Composer.

When your machine is prepared, it’s possible you’ll set up the Laravel framework using Composer:

composer create-project laravel/laravel quickstart --prefer-dist

Note: We can replace quickstart from your project name.

Laravel Application Structure

The software structure in Laravel is principally the structure of folders, sub-folders and files included in a project. We created a project in Laravel, we get an outline of the application structure as proven within the picture below.



It is the application folder and contains your entire source code of the project. It accommodates events, exceptions and middleware declaration. The app folder includes various sub folders as defined below:


Console contains the artisan commands necessary for Laravel. It features a listing named Commands, the place all of the commands are declared with the appropriate signature. The file Kernal.php calls the commands declared in Inspire.php. If we have to name a particular command in Laravel, then we must always make acceptable modifications on this directory.


This folder incorporates all of the methods wanted to deal with exceptions. It additionally incorporates the file handle.php that handles all of the exceptions.


The Http folder has sub-folders for controllers, middleware and software requests. As Laravel follows the MVC design pattern, this folder consists of model, controllers and views defined for the particular directories.

The Middleware sub-folder consists of middleware mechanism, comprising the filter mechanism and communication between response and request.

The Requests sub-folder consists of all of the requests of the application.


The Jobs directory maintains the activities queued for Laravel application. The base class is shared amongst all of the Jobs and gives a central location to put them below one roof.


Listeners are event-dependent and so they include methods that are used to deal with events and exceptions. For example, the login event declared features a LoginListener event.


Policies are the PHP courses which incorporates the authorization logic. Laravel features a function to create all authorization logic inside coverage courses inside this sub folder.


This folder consists of all of the service providers required to register events for core servers and to configure a Laravel application.


This folder encloses all the application bootstrap scripts. It contains a sub-folder particularly cache, which includes all of the files related for caching a web application. You also can discover the file app.php, which initializes the scripts needed for bootstrap.


The config folder consists of various configurations and related parameters required for the smooth functioning of a Laravel application. Various files included inside the config folder are as shown within the picture here. The filenames work as per the functionality associated with them.


As the name suggests, this directory consists of various parameters for database functionalities. It consists of three sub-directories as given below −

  • Seeds − This incorporates the classes used for unit testing database.
  • Migrations − This folder helps in queries for migrating the database used within the web software.
  • Factories − This folder is used to generate giant variety of data records.


It is the root folder which helps in initializing the Laravel application. It consists of the next files and folders −

  • .htaccess − This file provides the server configuration.
  • javascript and css − These files are considered as property.
  • index.php − This file is required for the initialization of a web software.


Resources directory incorporates the files which enhances your web software. The sub-folders included on this directory and their function is defined below −

  • assets − The assets folder embody files such as LESS and SCSS, which are required for styling the web application.
  • lang − This folder consists of configuration for localization or internalization.
  • views − Views are the HTML files or templates which work together with end users and play a primary role in MVC architecture.

Observe that the sources directory can be flattened as an alternative of getting an assets folder. The pictorial representation of same is shown below −

Routes Directory

The routes directory hold all of the route definitions for your application. By default, several route files are included with Laravel: web.php, api.php, console.php and channels.php.

The web.php file hold routes which provide session states, CSRF protection and cookie encryption. Most of your route will be defined in the web.php file.

The api.php file hold routes that the RouteServerProvider places in the api middleware group, which provide rate limiting.

The console.php a file is where you can define all of your closure based console commands. Each closure is bounded to a command instance allowing a simple approach to interacting with each command’s IO method. This file does not define HTTP routes. Its define console based entry points into your application.

The channel.php file is where you can register all of the event broadcasting channels that your application supports.


This is the folder that stores all of the logs and needed files that are wanted frequently when a Laravel project is operating. The sub-folders included on this directory and their purpose is given below −

  • app − This folder contains the files which are known as in succession.
  • framework − It contains classes, cache and views that are known as frequently.
  • Logs − All exceptions and error logs are tracked on this sub folder.


All the unit test cases are included on this directory. The naming conference for naming test case classes is camel_case and follows the convention as per the functionality of the class.


Laravel is totally primarily based on Composer dependencies, for example to install Laravel setup or to incorporate third party libraries, and many others. The Vendor folder consists of all of the composer dependencies.

In addition to the above talked about files, Laravel additionally consists of another files which play a main role in numerous functionalities such as GitHub configuration, packages and third party libraries.

The files included within the application structure are shown below −

Web Server Configuration

Nginx Server

If we are using Nginx, the following directive in our website configuration will direct all requests to the index.php front controller. Add the below changes in the our default configuration file: – /etc/nginx/sites-enabled/default

location / {
    try_files $uri $uri/ /index.php?$query_string;


Laravel includes a public/.htaccess file that is used to provide URL without the index.php front controller in the path. Before serving laravel with Apache,enable the mod_rewrite module so the .htaccess file will be honored by the server.

RewriteEngine On

RewriteCond %{HTTP:Authorization}

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^ index.php [L]

Visit the URL:- http://YOUR_DOMAIN/quickstart/public_html

<— Previous Tutorial Next Tutorial —>


Please enter your comment!
Please enter your name here


Related Articles

Concept of Session in Laravel Tutorial

Sessions are used to store details about the user throughout the requests. Laravel supplies various drivers like file, cookie, apc, array, Memcached, Redis, and database to handle session data. By default, file driver is used as a result of it's light-weight....

Laravel Url Generation Tutorial

Our web application revolves around routes and URLs. After all, they're what direct our users to our pages. At the end of the day, serving pages is what any web application should do. Our users may...

Concept of Laravel Views Tutorial

In MVC framework, the letter "V" stands for Views. It separates the application logic and presentation logic. Views are saved in resources/views listing. Generally, the view contains the HTML which might be served by the application.
WP2Social Auto Publish Powered By :