- How to Install Laravel on Localhost XAMPP
- How to Install Laravel on Localhost XAMPP
- Hashvel Blog
- How to Install Laravel 5.6 with Xampp on Windows
- # What’s Cooking?
- # Laravel Basic Requirements
- # Xampp for Windows
- Download Xampp:
- Install Xampp:
- # Install Composer
- Download Composer:
- Installing Composer:
- # Install Laravel
- # Run Laravel Projects
How to Install Laravel on Localhost XAMPP
At first, you should install XAMPP on your computer. To install different versions of Laravel, the PHP version of your XAMPP program is very important.
How to Install Laravel on Localhost XAMPP
At first, you should install XAMPP on your computer. To install different versions of Laravel, the PHP version of your XAMPP program is very important.
To install Laravel, version 5.7 you need the following specifications:
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Ctype PHP Extension
JSON PHP Extension
BCMath PHP Extension
If you have a lower version of PHP, you should upgrade it.
Laravel needs the Composer program to manage its extensions. If you do not have this program, you can download it from the site of Laravel or via the website getcomposer.org.
After downloading Composer.exe, run it, in the installation process, if you are prompted for the php.exe path, its address in your system is xampp/php by default.
If the composer is installed correctly, you’ll see below picture by entering composer command in cmd.
Now to install Laravel on the localhost, type below command in cmd.
C:\ xampp>cd htdocs
Now in the corresponding path, enter the following command to create a new Laravel project:
Composer create-project —prefer-dist laravel/laravel new_project
Now, Laravel is being installed on your system. After installation, go to the new_project folder and execute the php artisan serve command.
C:\ xampp\ htdocs > Cd new_project
C:\ xampp\ htdocs \ new_project >php artisan serve
A new message will be displayed on the server and your work on cmd will be completed.
Just open your browser and enter one of the addresses below.
http: // localhost / new_project / public
At this moment, your new Laravel project will be successfully installed and run.
Hashvel Blog
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.
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
Step 2:
You will see primary Xampp setup screen, click Next
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
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
Step 5:
Next, you can choose if you want to know more about Bitnami, I’ll deselect the checkbox, and click Next:
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
Step 7:
The installation process will finally begin and will take few minutes to unpack files and install them.
Step 8:
If you are prompted with a dialog box seeking firewall permissions, click on Allow 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.
Step10:
In a moment, the screen to set default language will be shown. I’ll go with default selected option and click Save.
Step 11:
The Xampp Control Panel will be up.
Step 12:
Start Apache and MySQL Modules by clicking Start for each one. This will confirm the successful installation.
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.
Also, to work with MySQL database, check localhost/phpmyadmin
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.
Download Composer:
Firstly, download the windows installer for the composer from the official composer page.
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.
Step 2:
Composer setup needs to check the PHP configs, keep the default settings and click Next.
Step 3:
Since we won’t need any proxy, we can go with the default settings and click Next.
Step 4:
The installation setup is ready, so confirm it with the Install button.
Step 5:
Composer installation process will initiate.
Step 6:
The screen will prompt with some information. Though we won’t need those steps, read it and click Next.
Step 7:
Once the installation process completes, click on Finish button.
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.
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:
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:
Optionally, you can also create Laravel project via composer:
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.
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:
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:
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:
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.