Install Laravel In a Fresh Windows Computer
Tags: laravel, php, mysql, windows
Published: 2023-08-30 18:22:06

## What is Laravel 
Laravel is a PHP framework. Learn more from Laravel [Official Doc](https://laravel.com/docs/10.x)

## Install Laravel / Get Started with Laravel

Laravel is a PHP framework and PHP is a language that is used for backend development purposes only. 

Unlike JavaScript, which is run on the browser, or on node.js which need to be installed on the computer. All modern browsers have a JavaScript engine like Chrome has V8. So to run JavaScript or get started with JavaScript language we need a browser or Node JS installed.

But PHP runs only on the server, which needs to have server software like Nginx or Apache. Our computer, which is not for server purposes use, does not have any server software, so to run or get started with PHP-Laravel we need to have Nginx or Apache server + We also need to have a Database client like MySQL or PostgreSQL or any other DB system for data storage. 

All of this software and more comes with useful [Laragon](https://laragon.org/) software which gives us a WAMP stack local server environment. 

## But, Before That

Before installing Laravel we need to have installed and configured both **PHP latest version** and **Composer**

## Download PHP and configure

1. For Windows we need to download thread safe zip file from the official PHP website [Download PHP 8.2](https://windows.php.net/download#php-8.2)
![Download Thread safe PHP 8.2 for Windows OS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hthhreube5zwsx7owtf.png)
2. Unzip downloaded file
3. Put this unzip file into C Drive > Program file
4. Copy that folder path `C:\Program Files\php-8.2.9-Win32-vs16-x64`
![Copy PHP folder path](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/clc9q0w5ieyp0nefqk0g.png)
5. Search in the Windows console as `Edit the system environment variable`, it will open the system properties window
![Search Environment variable in Windows command prompt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jes1szifcn6e3vkbk7xw.png)
6. Then Click `Environment variable`
![Click Environment Variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d2yrd3e26sr4zn79vzkl.png)
7. In the below **system variable** section click the `path` option
![System variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8g2drj1hya4e7l8w8ouy.png)
8. Then click `New` and put that php path link `C:\Program Files\php-8.2.9-Win32-vs16-x64`
![Paste the PHP folder path in the Environment variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k9gf2c8bjvfnfmht1d7x.png)
9. Press Ok Ok Ok and close all windows.

## Install Composer

* [Download Composer](https://getcomposer.org/) from official website  and Install Composer
* Download this `Composer-Setup.exe` file
![Composer Setup File](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/04jutev8zbal0mise5rz.png)
* When Installing it will automatically detect our PHP file path
![Composer detects PHP path automatically](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7itxucfhu34kwykr24j2.png)

## Install Laragon

Install Laragon is easy but, keep in mind, install Laragon in **D/F Drive**, except **C drive**. If you face any problem with Windows later, then you need to install Windows, and then all of your projects in Laragon will gone! 

## Download and configure PHPMyAdmin

After installing Laragon we need to download and configure the PHPMyAdmin MySQL DB console.

* [Download PHPMyAdmin](https://www.phpmyadmin.net/) MySQL from official website 
* Put this file into Laragon **root www** folder. You can go root folder in many ways
![Go Laragon www root folder from drive folder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/am0vsmb2joz7wsuckxuv.png)
Or 
![Go Laragon www root folder from Laragon console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bb3bet29msm3ki4hkovx.png)
* Unzip the file and delete the zip file.
* Rename this PHPMyAdmin file for shortcut use as **pmad** 
* Into the **pmad** folder, rename this **config.sample.inc.php** as **config.inc.php**
* Open this file into vs code or any other code editor
* line number 32, make it true
![Make The AllowNoPassword in config.inc.php true](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7900wbirnwzktenjygvk.png)
* After that we can get this PHPMyAdmin console from the browser
* But before that, we need to press **Stop** & **Start All** Laragon all server and ports

## Create Database in the PHPMyAdmin console

* in browser write **pmad.test** and write username as **root**, then log in
![log into PHPMyAdmin console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2y1su0jfk1nttzei043p.png)
* Into the pmad console create a db project as you wish, we can write **laravel**
![Create a database table name as laravel in PHPMyAdmin console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vdcr771lu4rz7jkkwuc8.png)

## Enable PHP essentials extensions

Now we need to enable some essential extensions in PHP, without those our Laravel project will not run. These are,

* curl
* fileinfo
* mbstring
* openssl
* pdo_mysql

and more

Go to PHP folder > open **php.ini** file into code editor > enable these extensions

## Install Laravel with Laragon Console

> Go ⟶ Menu ⟶ Quick App ⟶ Laravel ⟶ Give name ⟶ Project created

![Install by Laragon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/us0i0bzya0hyc1tswryv.png)

## Install with Composer

Laravel uses [Composer](https://getcomposer.org/) for dependencies, just like JavaScript uses Node for dependencies. For installing any packages or extensions in PHP-Laravel we need Composer, like npm for node/JavScript language.   

* Check composer in command prompt: `composer -v`

If Composer is not updated then run the update command

* Update composer: `composer self-update --preview`

* Finally Create a Laravel project with the composer in the Laragon root folder

```sh
composer create-project --prefer-dist laravel/laravel myApp
```

## Install with Laravel CLI

Installing Laravel with Laravel CLI is so easy and simple.

* First run this command in Laragon root folder `composer global require laravel/installer`
* Then simply install Laravel project by running command `laravel new myApp`

## After Laravel Install

After installing Laravel we need to configure **env** file in Laravel

* Copy **.env.example** and paste a new file as **.env**
* Now we need to put our DataBase Name, pmad console username and password in **.env** file 
* After that we need to have our project APP_KEY, run Laravel command `php artisan key:generate` 
![Configure Laravel .env](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b549l66gbwtruf1f90vy.png)
* After that need to migrate our PHP table into the Database console, run the command `php artisan migrate`
* And Finally we need to open our Installed Laravel project in the browser as `php artisan serve`

---
If you face any problems, email me at **mhasan.meet@gmail.com**