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
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.
Once, the download completes, initiate the installation process. It has quite a straightforward installation UI. Let me walk you through it:
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
You will see primary Xampp setup screen, click Next
The next screen will ask you to select the components to set up; we will choose the default setup, so just click Next
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
Next, you can choose if you want to know more about Bitnami, I’ll deselect the checkbox, and click Next:
The ready to install screen. You can go back from here if you want to change any of the previous settings or click Next
The installation process will finally begin and will take few minutes to unpack files and install them.
If you are prompted with a dialog box seeking firewall permissions, click on Allow Access.
Once the installation is successfully completed, keep the Do you want to start the Control Panel now? Checkbox selected and click on Finish.
In a moment, the screen to set default language will be shown. I’ll go with default selected option and click Save.
The Xampp Control Panel will be up.
Start Apache and MySQL Modules by clicking Start for each one. This will confirm the successful installation.
You can also check the same in browser. Just shoot
localhost in the address bar, and it will open the default
Also, to work with MySQL database, check
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.
Firstly, download the windows installer for the composer from the official composer page.
You can install the Composer on your own. Here are the steps for reference:
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.
Composer setup needs to check the PHP configs, keep the default settings and click Next.
Since we won’t need any proxy, we can go with the default settings and click Next.
The installation setup is ready, so confirm it with the Install button.
Composer installation process will initiate.
The screen will prompt with some information. Though we won’t need those steps, read it and click Next.
Once the installation process completes, click on Finish button.
We can confirm the composer installation by running
composer in the terminal or git bash. This command lists information and available commands in Composer.
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"
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.
# 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
And then, open the following link in the browser:
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:
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
localhost. To do so, edit the hosts file. It is located within
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.
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.