How to install Laravel with XAMPP on Windows Using Composer

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

open command

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 directoryto 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.

start downloading dependencies for laravel

This installation may take a few minutes after executing the above command, so wait until you get success message like in the below image.

completed downloading dependencies for Laravel

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.

run laravel project

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.

5 Comments
  1. emilio says

    and how I edit the hosts file if it is .txt?

    1. Vikas Kumar says

      Hello,

      First Right click hosts file and open file in notepad or any php editor.

      Thanks

  2. Shailesh Jha says

    composer create-project –prefer-dist laravel/laravel laravelproject
    After run command getting error –

    [ErrorException]
    "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
    

    do you know why ?

    1. Vikas Kumar says

      Hello Shailesh Jha,
      1) Try to update Composer, do it run below command in command prompt –

      composer self-update
      

      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.

      1. Shailesh Jha says

        After reinstall worked for me. Thanks a lot bro.

Leave A Reply

Your email address will not be published.