Laravel, a free and open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller architectural pattern is getting more popular in nowadays. Laravel released it’s new 5.7 version on September 4th, 2018. It includes some extra features which help developers in many ways. Yes, Laravel is getting more popular among developers. In usual, developers choose Mac OS or any other Linux variants for the developing purposes. But we can not neglect the value of Windows the most using operating system in the world. Here I am explaining that how to install and setup Laravel 5.7 on Windows 10 using XAMPP
1. INSTALL XAMPP
XAMPP is the most popular PHP development environment.XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to use.
XAMPP can be easily installed using the below URL.
Just install the latest version (7.2.9) from the list. It is to be noted that only 32-bit version is available for Windows platform, but it works fine in 64 bit Windows.
Now you will get a XAMPP exe file on Downloads directory. Install this application by double-clicking it (Neglect the warnings by Windows). I have shown the screenshots of installation steps below.
2. INSTALL COMPOSER
The composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries. So we need to install composer before installing Laravel. Just follow the below URL and download the Composer-Setup.exe file.
Just install this exe file as you did before. I have shown some screenshots of the installation steps.
3. INSTALL GIT
We need a terminal to go forward in this tutorial. Windows have Command Prompt and Powershell as default terminal but it feels a little bit uncomfortable. So I personally recommend git bash in place of Command Prompt. Git can be installed using the below link.
Just install the exe file. I am not explaining the steps because you can execute the commands on Command Prompt also.
So after successful installation of Git, right click on the desktop and select Git Bash Here. This will open up a terminal and from now on, you can execute all the commands in the below steps within Git Bash. But first Chain Direct to the home directory using the below command.
4. INSTALL LARAVEL
Now its time to install Laravel on the using composer by running the below command on git bash.
composer global require "laravel/installer"
5.CREATING NEW APPLICATION
After successful installation of Laravel, you can create a new app with the below command. AwesomeProject is the name I choose for my project
composer create-project --prefer-dist laravel/laravel AwesomeProject
Now, wait for some time to complete the creation.
6. CHOOSING THE CODE EDITOR
You can choose your own favorite code editor for editing your project. But in my case, I choose Visual studio Code(VS code). Using the below link, you can download VS code for Windows and install.
7. DIRECTING TO YOUR PROJECT FOLDER AND EDITING
You can manually open your project directory(AwesomeProject) on VS code. You can also use git bash to open up the project on VS code using the below command.
cd ~/AwesomeProject code .
8. CREATING DATABASE
You have to create a database on your Mysql server which is the DB of your Laravel application.
- Direct to the URL below.
Enter username and password(As a default, the username and password will be root).
- Click on the New tab
- Enter a database name
9. EDIT .ENV
Edit the .env file in your project folder. If there is no .env file in your project, you have to create a file and paste all the contents from sample.env to the file you created and save the file with a .env filename.
DB_DATABASE=(The database name you created earlier - awesome_project_db) DB_USERNAME=(Your Mysql username. Default: root) DB_PASSWORD=(Your Mysql password. As a default, blank)
10. MIGRATE DATABASE
You have to migrate the database from your Laravel application to your localhost using the below command.
php artisan migrate
11. RUNNING YOUR APPLICATION
php artisan serv
Open a new tab on your browser with the URL below and you can the home page of the Laravel app we created.
If you wanted to open the app in another port,
php artisan serv --port=9000
It will open the app with an address below.
If you are using Ubuntu OS, take a look at the tutorial below.
Have a nice code !