Laravel

How to Install Laravel 5.6 with Xampp on Windows

March 1, 2018

author:

How to Install Laravel 5.6 with Xampp on Windows

It is no news that Laravel is gaining immense popularity for its simplicity and robust features. Laravel is a PHP framework. Like any other framework, it needs a developing environment. You can use Laravel specific environments like Homestead or Valet, but if you are looking to setup Laravel with a Xampp, the well-known platform for PHP development, stick around.

# What’s Cooking?

Some fast Installations. We will start with installing Xampp in Windows, then move forward to install Composer and will finally install Laravel. We will also create a sample project and run in the browser.

# Laravel Basic Requirements

Since we want to work with the latest version of Laravel, i.e., v5.6, let us first have a look at the basic requirements:

  • PHP >= 7.1.3
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension
  • Ctype PHP Extension
  • JSON PHP Extension

# Xampp for Windows

Download Xampp:

As we saw in the basic requirements, we need PHP >= 7.1.3. So let us try and download the latest version of Xampp that supports PHP 7.2.2.

How to Install Laravel 5.6 with Xampp on Windows, Xampp Homepage

Install Xampp:

Once, the download completes, initiate the installation process. It has quite a straightforward installation UI. Let me walk you through it:

Step 1:
If you are installing Xampp for the first time on your machine, you may see a UAC warning; you may ignore it for now and click OK
How to Install Laravel 5.6 with Xampp on Windows, UAC Warning

Step 2:
You will see primary Xampp setup screen, click Next
How to Install Laravel 5.6 with Xampp on Windows, Xampp Welcome Screen

Step 3:
The next screen will ask you to select the components to set up; we will choose the default setup, so just click Next

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Select Components

Step 4:
You will be prompted to select the location to setup xampp. You may change it to D Drive or any other if you don’t want to lose the Xampp data during future system formats. I’ll go with the default setup and click Next

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Select Components, Select location

Step 5:
Next, you can choose if you want to know more about Bitnami, I’ll deselect the checkbox, and click Next:

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Select Components, Select location, Bitnami Information

Step 6:
The ready to install screen. You can go back from here if you want to change any of the previous settings or click Next

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Select Components, Select location, Installation Ready

Step 7:
The installation process will finally begin and will take few minutes to unpack files and install them.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Select Components, Select location, Installation in Process

Step 8:
If you are prompted with a dialog box seeking firewall permissions, click on Allow Access.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Select Components, Select location, Firewall Access

Step 9:
Once the installation is successfully completed, keep the Do you want to start the Control Panel now? Checkbox selected and click on Finish.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Installation Complete

Step10:
In a moment, the screen to set default language will be shown. I’ll go with default selected option and click Save.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Select Language

Step 11:
The Xampp Control Panel will be up.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Xampp Control Panel

Step 12:
Start Apache and MySQL Modules by clicking Start for each one. This will confirm the successful installation.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Run Apache and MySQL in Xampp

Step 13:
You can also check the same in browser. Just shoot localhost in the address bar, and it will open the default localhost/dashboard screen.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Run Xampp in browser

Also, to work with MySQL database, check localhost/phpmyadmin

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Run Xampp in browser, MySQL Homepage

That’s it. We successfully completed installing Xampp in Windows machine from scratch.

# Install Composer

Composer, a PHP package manager has used manage Laravel dependencies. Hence it must installed before setting up Laravel.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Composer Homepage

Download Composer:

Firstly, download the windows installer for the composer from the official composer page.
How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Download Composer

Installing Composer:

You can install the Composer on your own. Here are the steps for reference:

Step 1:
When you click on the downloaded installer, it will prompt the following screen. We don’t want to install the developer mode, so keep that unselected and click Next.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Step 1

Step 2:
Composer setup needs to check the PHP configs, keep the default settings and click Next.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Step 2

Step 3:
Since we won’t need any proxy, we can go with the default settings and click Next.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Step 3

Step 4:
The installation setup is ready, so confirm it with the Install button.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Step 4

Step 5:
Composer installation process will initiate.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Step 5

Step 6:
The screen will prompt with some information. Though we won’t need those steps, read it and click Next.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Step 6

Step 7:
Once the installation process completes, click on Finish button.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Step 7

Step 8:
We can confirm the composer installation by running composer in the terminal or git bash. This command lists information and available commands in Composer.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Run Composer Command

If you see the above output, the composer is setup successfully.

# Install Laravel

To install Laravel, we can Download the Laravel installer globally. Run it from any location:

composer global require "laravel/installer"
How to Install Laravel 5.6 with Xampp on Windows, Xampp, How to Install Composer in Windows, Laravel Global Command

Once this completes, optionally, you can go to C:\xampp\htdocs\ namespace and create a new folder to keep your Laravel projects aligned.

And from that specific folder, open a terminal and run:

laravel new firstProject

Optionally, you can also create Laravel project via composer:

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

And here’s the Laravel project directory schema.

How to Install Laravel 5.6 with Xampp on Windows, Xampp, Laravel Folder Structure

# Run Laravel Projects

Make sure that Apache and MySQL are running in Xampp Control Panel. You can run Laravel projects in various ways. Let us discuss them:
1. Artisan command
The most arbitrary way to run Laravel projects is with artisan command. Artisan is Laravel’s inbuilt command directory.

php artisan serve
How to Install Laravel 5.6 with Xampp on Windows, Xampp,How to Run Laravel in Browser

And then, open the following link in the browser:

localhost:8000
How to Install Laravel 5.6 with Xampp on Windows, Xampp,How to Run Laravel in Browser Welcome Screen

If you see the Laravel welcome page in the browser, congratulations! Laravel is successfully set up on your machine.

2. Public Directory
The other way to run Laravel projects is with localhost. If your projects are located within htdocs folder, you can also run Laravel application in a similar way to running core PHP projects:
localhost/Laravel_Projects/firstProject/public

Remember, the public namespace of Laravel project is the main endpoint for your application.

3. Xampp Virtual Host
We can also configure Virtual Host for Laravel Projects and add a relevant domain. To do so, open httpd-vhosts.conf which is located within C:\xampp\apache\conf\extra\httpd-vhosts.conf. Add following code snippet:

<VirtualHost laravel.test:80>
    DocumentRoot "C:\xampp\htdocs\Laravel_Projects\firstProject\public"
    ServerAdmin laravel.dev
    <Directory "C:\xampp\htdocs\Laravel_Projects\firstProject">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

This enables Apache server to listen to laravel.test. We now need to redirect laravel.test to localhost. To do so, edit the hosts file. It is located within C:\Windows\System32\drivers\etc.

Also, make sure that you open the file as an Administrator. Add:

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

127.0.0.1 laravel.test

Save the file and restart the system if required. You can then test the application with laravel.test in the browser.

It’s evident that all the three methods have the same output in the browser. You can choose whichever suits you best. We will use the first way, i.e., artisan command to test the application in future tutorials too. Its simple, fast and Laravel friendly.

Conclusion:

The post was all about setting up Laravel on a Windows Machine with Xampp. To start with, we installed Xampp. Then we installed a Laravel dependency called Composer. And Finally installed Laravel. I walked you through the installation process step by step from scratch. We also created a fresh Laravel project and at the end, discussed various ways to run a Laravel application with Xampp.

Questions & Comments:

Thank you for reading. If you face any issues while installing Xampp or Laravel in your Windows system, share them in the comment section below.

Leave a comment

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