Learn Laravel Step By Step based on the project

Hey Developer I want to share some basic concepts of Laravel starting from scratch to advanced concepts of Laravel based on projects.

In this post, I want to cover the very basic concept of Laravel.

The project we have developed on these posts is the Employee Management System(EMS).

In this article, we cover the following

  1. What is Laravel
  2. What is Composer
  3. Laravel Code Structure.
  4. How to Configure a project with a database
  5. Integration of Admin template with Laravel project
  6. How to create Views in Laravel
  7. How to Create Route
  8. How to Create a Controller
  9. How to Create Models
  10. How to Create Tables
  11. How to Migrate Tables
  12. How to Join two or more tables
  13. How to use Cascade Selection in Dropdown

What is Laravel?

Laravel is a PHP framework that is used to develop web applications. Laravel is very powerful in developing web-based software systems. It is a very lightweight PHP framework.

By using Laravel we develop simple and very large projects in simple and easy ways.

In Laravel Code reusability concept is very used. Laravel has a very elegant syntax. For that reason most open-source developers use Laravel. Laravel can be integrated with any front-end JavaScript or type script technology. At that time Laravel acted as backend development.

What is Composer?

Composer is a package manager software in PHP. We can use a composer for managing php project version and vendors downloading, controller plugins versions.

Composer setup we can use in all OS(operating systems), and we can install on Windows, Mac, Linux, and others what we want.

Installing of Composer

Composer installation is a very easy tip. To Install Composer on your machine follow the following step.

Step 1: download Composer setup from the composer.org website.

Step 2: Click the composer.exe file and install it.

Step 3: Click Next and  give the PHP folder director that the composer use

Step 4: After completing the Installation steps click finish and restart your PC.

After restarting your pc composer can work properly.

Basic Pre requirement for Laravel setups

To download Laravel we must check our computer or machine must have the following things

  1. PHP
  2. Local server XAMPP or WAMP
  3. Composer
  4. Code Editors

The above setups may require installing and running Laravel functionally.

How to Download Laravel Setups

To download Laravel setups we can use two methods.

Method 1: Download Laravel by using Composer.

Downloading Laravel by using Composer takes easy steps.

Step 1: go to Laravel documentation and click Laravel with composer

Type the following code on the terminal

 Composer create-project –prefer-dist larvae/laravel ems

The above command is used to download the Laravel setup from the Laravel website or portals.

After typing the above command you can get the following folders

The above image shows successful downloading of Laravel setups for our projects.

After downloading all setups we must change our working directory to our project folders.

To change our folder to working director use these commands.

     cd ems
cd=> Change directory
php artisan ser

After changing the directory to our project folder run the project by using the below commands

    Php artisan serve
then you can get the URL of our project run on like these Run these port

Code Structure of Laravel Project

Laravel has its own code structure whereas another open source has its own code structures. Laravel has a very clear and native code structure. Any Developer can understand Laravel code structure in simple ways.

Let’s talk about Laravel code structures starting from configuration to database migration and artisan commands.

Laravel has different files and folders. Laravel has 26 folders and files. Each folder and files have their functions for the performance of the system.

Code Structures

App: The app folder has the main function of Laravel setups. It has five folders in it

Folders in Apps are Console, Exceptions, HTTP,  Models, and Providers.

HTTP has different folders and files, and the functions of HTTP are used to create Controller and Middleware.

If you want to see middleware and controller you must go to app\http\controllers or app\http\middleware.

How to configure Laravel With Database

Laravel configuration is very easy and simple ways.

To configure Laravel we must go to the .env file and configure it.

Laravel can configured with different databases. Laravel can connect with MySQL, SQLite, SQL, Postgres and other databases.

As the above image shows these projects was connected with MySQL database technology with port 3306 and

database name:emsdb

username: root


host: localhost or

Integration of Admin template with Laravel project

Admin template integration with Laravel is a very interesting part of these posts. Integration of the admin template to fresh Laravel is very important if we consider the following steps.

Step 1: Download any admin template that you want online. For these posts, I have used adminlte.io

Step 2: After downloading the admin template and extracting it on your computer

Step 3: Open extracted file and open index.html by browser

Step 4: View the source code of the open project by using ctl + U to view HTML of the project.

Step 5: Copy resource files that were used during admin template development and past on  Laravel project public folders.

Those folders are dist, plugins, and vendors

Finally, After copying and pasting to Laravel, we must create a view on Laravel.

How to Create View

To create View in Laravel we must select folder resource and view folder that is found in the resources folder.

After selecting the view folder we must create a blade template, Laravel uses blade template only in view files so we have to create a blade template like master_layout.blade.php

Master_layout is the name of the file, .blade is the blade template, .php is the extension

After creating the view file copy all files from index.html from minute template to these master_layout.blade.php files.

You can download it from these links.

This picture shows how to create a view in Laravel on blade

To access resource on Laravel we use {{asset(‘resource locations’)}}

How to Create Route In Laravel

The route is the main basis of any applications. An application that has no route, cars like without ferine.

Route tells where our project goes and looks.

In Laravel we can create routes in two methods. My terminal or by adding routes/ web.php files.

To create routes we must go to folder routes and edit our routes in web.php files.

The above image shows how to create a route in Laravel.

If we want to add other routes we use similar to the above syntaxs.


Or Using controller Name


How to Create a Controller

The controller is the mediator of models and view files. If we want to show some data to use we must use a controller or route.

To create a Controller we can use the following commands

Php artisan make: controller ControllerName –r

Php => package of the project

Artisan => is the name of the command line interface

Make: controller => create a new controller

ControllerName= The name of the controllers

-r = create resource in controller functions, like index, show,create, store,update, edit,destroy

How to Create a Model in Laravel

Model in Laravel where the business logic area takes place. In the model we can write relationships of tables one to one, one to many, and many to many with pivot tables and fillable, has factory can also written in the model function

To create a model in Laravel follow the following command

type php artisan make: model models name –m

Make: model used to create models

ModelName: Model we want to create it and

-m migrate to our database migrations.


Laravel is a very useful full php open-source framework. Nowadays many developers use Laravel for developing systems.

To create a Controller:

php artisan make: controller ControllerName

To create Model

php artisan make: model ModelName

Author: bbnadmin

3 thoughts on “Learn Laravel Step By Step based on the project

Leave a Reply

Your email address will not be published. Required fields are marked *