In this article we will give you a step-by-step guide on how to install Laravel with XAMPP on Windows Using Composer. Through Composer it’s simple and easy to install Laravel with XAMPP.
# Server Requirements
Since we want to work with the latest version of Laravel 5.6, make sure your server meets the following 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
For more information, you can check the Server Requirements from Laravel official site.
# Install XAMPP
First thing you need to do is download the latest version of XAMPP that supports PHP 7.3.1 and Install it on Windows. For more details, see our step by step guide on How To Download And Install XAMPP On Windows.
# Composer
Once you have downloaded and installed XAMPP on Windows, then you need to do is Download Composer for Windows and Install it. For more details, see our step by step guide on How to Install Composer On Windows With XAMPP.
Laravel utilizes Composer to manage its dependencies. It must installed before setting up Laravel.
Once you successfully installed the Composer, open the command prompt. To open it, press Win + R keys on the keyboard, type in cmd and press the OK button
Then type composer and press enter in the command prompt and you will get following response like in the below image.
# Install Laravel Framework
To install Laravel, First of all, you have to go C:/xampp/htdocs directory, to navigate it type following command in your command prompt:
cd c:/xampp/htdocs
Now we are ready to install Laravel, run the following command to install latest Laravel version:
composer create-project --prefer-dist laravel/laravel laravelproject
After running this command it should start downloading dependencies that are required to create the Laravel project.
This installation may take a few minutes after executing the above command, so wait until you get success message like in the below image.
After executing this command, it create a folder ‘laravelproject‘ under C:/xampp/htdocs directory with all it’s dependency.
When it completed, it will create following directory schema:
# XAMPP Virtual Host
We need to configure a Virtual Host in XAMPP for a Laravel project and in this example we want to configure the domain localhost.laravelproject.com for our project. To do so, edit httpd-vhosts.conf file which is located within C:\xampp\apache\conf\extra\httpd-vhosts.conf
Add following code snippet at the end of your file:
# VirtualHost for localhost.laravelproject.com <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/laravelproject/public" ServerName localhost.laravelproject.com <Directory "C:/xampp/htdocs/laravelproject/"> Options Indexes MultiViews FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost>
After this, apache server is listening to localhost.laravelproject.com connections, but we have to configure our hosts file that allows to redirect localhost.laravelproject.com to the localhost , to do so, edit the hosts file which is located within C:\Windows\System32\drivers\etc
Add following code snippet at the end of your file:
127.0.0.1 localhost 127.0.0.1 127.0.0.1 127.0.0.1 localhost.laravelproject.com
Now everything is ready, restart the Apache server using the XAMPP control panel and type this URL http://localhost.laravelproject.com in your browser and press enter.
Final Words
That’s it! I hope this article helped you learn to how to install Laravel with XAMPP Using Composer.
Please feel free to comment below, your suggestion and problems if you face – we are here to solve your problems.
and how I edit the hosts file if it is .txt?
Hello,
First Right click hosts file and open file in notepad or any php editor.
Thanks
composer create-project –prefer-dist laravel/laravel laravelproject
After run command getting error –
do you know why ?
Hello Shailesh Jha,
1) Try to update Composer, do it run below command in command prompt –
If above command don’t fix your problem then reinstall composer, For more details, see our step by step guide on How to Install Composer On Windows With XAMPP.
Let me know.
After reinstall worked for me. Thanks a lot bro.
good day, cannot edit the host file, saying access deny
I cant access any of my localhost examples now and I can only see the laravel. how I get to see my other localhost/end.php examples?
Microsoft Windows [Version 10.0.17763.615]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\Brownie>cd c:/xampp/htdocs
c:\xampp\htdocs>composer create-project –prefer-dist laravel/laravel laravelproject
[Composer\Downloader\TransportException]
The “http://repo.packagist.org/p/provider-2013%24b1660752b71f4e8b6b9d3130551f6bcfb3c1e896bd75f81cf5ca5a06499fb157.j
son” file could not be downloaded: failed to open stream: HTTP request failed!
create-project [-s|–stability STABILITY] [–prefer-source] [–prefer-dist] [–repository REPOSITORY] [–repository-url REPOSITORY-URL] [–dev] [–no-dev] [–no-custom-installers] [–no-scripts] [–no-progress] [–no-secure-http] [–keep-vcs] [–remove-vcs] [–no-install] [–ignore-platform-reqs] [–] [] [] []
it is very helpfull documentation, thank you..
there is a problem with me in composer i just setup the composer and i put the command of php artisan make:auth and there is a message says the make:auth not defined are there any one appeared that problem before
Thank you very much. Very helpful!🙌
http://localhost.laravelproject.com I’m getting redirected to my default directory: D:/xampp/htdocs/
i am getting redirected to my default directory:C:/xampp/htdocs/
Hey Tobi !
you have to right click on host file, then go to properties>security. Then edit change permissions for the USERS (under group or username select users) and not for others from read/read & execute to Full Control and applying these settings will solve your problem and you will get access.
Thank you so much I installed laravel successfully using the steps you provided.
I managed to do everything up to the point where i had to paste the last code to the host file but when I tried to paste “http://localhost.laravelproject.com” on my browser, it shows “This site cant be reached IP address could not be found”
Nevermind, I got it already.
Thank you!
It has been very useful
Ran into this post today. Very helpful. Thank you a ton.
After following the guide above, and trying to start the server as you said, the server is shutting down, it is not connecting to laravel nor my previous files before dowloading composer. What can I do
Well done, thanks. It perfectly works.