Getting started with Laravel

This post is for those who are willing to start learning Laravel and I will tell you how to setup environment for efficient and effective learning and creating applications with Laravel.

So first of all what is Laravel ?

Laravel is a web application framework with elegant syntax build over core php following the concepts of MVC (Model, View, Controller). For those who don’t know about MVC. It is a design strategy (pattern) that separates the application logic(Controller), frontend logic(View) and database logic(Model).

MVC diagram
MVC diagram

Why to use Laravel ?

Before diving deep into Laravel lets understand why do we need Laravel when it is doing the stuff which can be done in core php. So the answer is really simple. As I told earlier it is a framework that means it gives us a pattern of how to create the application. Also it have many predefined functions that can make your life easier and save you from hell lot of overwork that we used to do in core php.

So, those who are still hesitating to leave core php. It’s time for stop hesitating and getting started with it !!!

Enough of theory, let’s deep dive into it and see how to install Laravel on windows and setup the environment.

As there are many ways to install Laravel . I will tell you the most basic way of installing it. Considering you already worked on php and have php and any virtual server(wampp,xampp etc) installed on your system. Personally I would recommend xampp for all the beginners.

First of all you need to install composer . You will find it here.

After installing composer just open your terminal and for directly creating a project type

composer create-project laravel/laravel name-of-app

Or if you want to first install laravel run this in your terminal

composer global require laravel/installer 

Then run

laravel new name-of-app

That’s it… Congratulations you have successfully created a new fresh Laravel project.

After installing just cd into your app directory and type

php artisan serve

Type localhost:port-number(you can get url and port number from your terminal) into your browser and that’s it you will see Laravel appplication running on your browser.

Don’t forget to run your virtual server first (xampp or wampp).

Now let’s setup database for our application:

Create a database on your db manager (like phpmyadmin)

Navigate to the .env file in your laravel app and change the DB_DATABASE variable value with the db name you just created

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=db_name

DB_USERNAME=root

DB_PASSWORD=

Change the variables as per your requirements.

That’s it… You have successfully configured your first Laravel app.

HAPPY CODING !!!

If you like the blog, please hit that clap icon and comment if you have any issue or want any other blog on Laravel. Also do follow me and contact me if you need any guidance on your Laravel journey.

NOTE: As of now the current version of Laravel is 8.1 and Laravel team introduces a new version in every 6 months. I would strongly recommend everyone to read their documentation atleast once. Everything which i told here is there in Laravel documentation.

WEB LEARNER