How to Install Laravel on Windows Localhost

8 Min | June 14, 2024

Laravel is a robust open-source PHP web application framework that provides robust tools and an expressive architecture for building modern web applications. It is widely adopted by developers due to its elegant syntax, extensive documentation, and vast community. While Laravel is designed for production environments, setting up a local development environment for testing and development purposes is essential.

This article will provide a step-by-step guide to installing Laravel on your local machine using XAMPP, a free and open-source cross-platform web server solution. A local development environment allows you to experiment with Laravel’s features, debug issues, and test your applications before deploying them to a live server.

Our guide is designed to assist developers of all skill levels, from beginners to experienced ones, in successfully setting up Laravel on their local machines. By following the instructions, you can create and run Laravel projects locally, enabling you to explore its powerful features and capabilities efficiently. Let’s get started.

Why Do You Need to Install Laravel on Localhost?

For developers and designers working with Laravel, setting up a local development environment is crucial. Here are a few key reasons why you should install Laravel on your local machine:

Testing and Experimentation: A local environment allows you to safely test new features, updates, or patches before deploying them to a live production server. This minimizes the risk of introducing bugs or issues affecting your live applications.

Development Workflow: When working on client projects or personal applications, you can make changes, experiment with different approaches, and debug issues locally without impacting the live site. This streamlines your development workflow and enables you to catch and fix problems before pushing changes to a production environment.

Multiple Projects and Versions: Installing Laravel locally enables you to work on multiple projects simultaneously, each with its configuration and dependencies. You can also test your applications against different versions of Laravel without conflicts.

Laravel Installation Requirements

Before proceeding with the Laravel installation on your local machine, ensure that your system meets the following requirements:

  • Web Server: Apache or Nginx (Laravel provides built-in support for both). 
  • PHP: Laravel requires PHP 8.0 or later, along with several extensions such as BCMath, Ctype, JSON, Mbstring, OpenSSL, PDO, Tokenizer, and XML.
  • Database: Laravel supports various database systems, including MySQL, PostgreSQL, SQLite, and SQL Server.
  • Composer: Laravel utilizes Composer to manage dependencies and install packages.

Once you have verified that your system meets these requirements, you can proceed with the step-by-step installation process to set up Laravel in your local development environment.

Install Laravel on Localhost Step-by-step

Follow these steps to install Laravel on Localhost using the xampp server.

Step 1: Install the XAMPP Server

  1. First, go to the Apache Friends website and download the XAMPP software. Choose the version compatible with your operating system and meets your specific requirements.
laravel on localhost
  1. Run the downloaded installer and follow the instructions below to complete the installation.
  2. Click on the “Next” button.
laravel on localhost
  1. Now, continue with the default selection shown in the image, and click on the “Next” button.
laravel on localhost
  1. The default location is C:\xampp, but you can choose the location according to your installation folder preference. Once you have made your selection, click on ‘Next.’
laravel on localhost
  1. Click the ‘Next’ button.
laravel on localhost
  1. The setup is now ready to install. Please click the ‘Next’ button.
laravel on localhost
  1. Please wait until the process is complete, as the setup wizard will install the XAMPP server on your computer. Once the installation is complete, the setup will automatically run.
laravel on localhost
  1. Once the setup process is completed, you will see this message:

Do you want to start the Control Panel now?

  1. Click the “Finish” button to proceed further and exit the setup. 
  2. You can now access the XAMPP control panel.
laravel on localhost

Step 2: Configure XAMPP

After launching the XAMPP server, we need to configure it. Follow these instructions to configure XAMPP on your system.

  1. In the XAMPP Control Panel, start the Apache and MySQL services by clicking the “Start” button next to each service.
laravel on localhost
  1. Ensure that the status indicator for both services turns green, indicating they are running.
laravel on localhost
  1. Click on the “Config” tab in the Apache section of the XAMPP Control Panel, locate the “PHP (php.ini)” file, and open it using a text editor.
laravel on localhost
  1. In the php.ini file, uncomment (remove the semicolon) the following lines:

   – extension=gd

   – extension=intl

   – extension=soap

   – extension=sockets

   – extension=sodium

   – extension=xsl

  1. Increase the memory limit by setting `memory_limit = 4G`.
  2. Save the changes to the php.ini file and close the text editor.
  3. Restart the Apache and MySQL services in the XAMPP Control Panel.
laravel on localhost

Step 3: Create a Database with phpMyAdmin

  1. Open your web browser and navigate to http://localhost/phpmyadmin.
  2. Log in to the phpMyAdmin account using your credentials (if prompted).
  3. Click on the “Databases” tab and enter a name for your new database.
laravel on localhost
  1. Click the “Create” button to create the new database.
laravel on localhost
  1. Create a table, enter columns, and then click on the Go button.
laravel on localhost

Step 4: Download and Install Composer

  1. Visit the official Composer website and download the installer for your operating system.
laravel on localhost
  1. Download this Composer – setup.exe file.
laravel on localhost
  1. Run the downloaded installer and follow the instructions below.
  2. Select a mode for installation; it is better to choose the recommended one.
laravel on localhost
  1. Click “Next.
laravel on localhost
  1. Locate the PHP file address in the XAMPP folder and enter the location here. Then, check the “add this PHP to your path” box and click on the next.
laravel on localhost
  1. Add a proxy URL if you want to, or skip it and click the “Next” button. (Optional)
laravel on localhost
  1. Click on the “Install” button to begin the installation process.
laravel on localhost
  1. Click on the “Next” button.
laravel on localhost
  1. Click on the “Finish” button to complete the installation.
laravel on localhost
  1. Open the Command Prompt and run the `composer` command to verify that Composer is installed correctly.
laravel on localhost

Here you go! We have successfully installed the Composer on our system.

Step 5: Install Laravel

We are done with all the installations and configurations. Now, our local environment is ready. We can install Laravel on it. Follow these instructions to install Laravel on your local environment.

  1. Open the Command Prompt and navigate to the htdocs directory within your XAMPP installation (e.g., `C:\xampp\htdocs`) using the cd command.
laravel on localhost
  1. Run the following command to create a new Laravel project:

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

              Replace `new_project` with your desired project name.

  1. While running the above command, you might get this error message.
laravel on localhost
  1. This error can arise if your zip extension file is not enabled or git is not installed.
  2. You can solve this issue by installing Git from its official site on your system and following the instructions provided in the Git official documentation. 
  3. This error mainly occurs because the zip extension file is not enabled. So, let’s solve this issue.
  4. Go to the C:/xampp/php/ folder and locate the php.ini file.
laravel on localhost
  1. Right-click on this file and open it with the Notepad editor.
laravel on localhost
  1. Locate the extension=zip variable and remove the semicolon from the start.
laravel on localhost
  1. Save the file.
laravel on localhost
  1. Now, restart your command prompt, navigate to the C:\xampp\htdocs folder, and run the composer create-project –prefer-dist laravel/laravel new_project command again.
laravel on localhost
  1. It will start downloading and installing Laravel locally on your system. You can see it’s downloading and unpacking the necessary packages and dependencies.
laravel on localhost
laravel on localhost
  1. Wait for Composer to download and install all the required Laravel dependencies.
laravel on localhost
  1. It is installed successfully. Now the installation is complete, navigate to the newly created project directory:

 cd new_project
laravel on localhost
  1. Start the Laravel development server by running the following command:

php artisan serve
laravel on localhost
  1. You will see a message indicating the development server is running and providing a local URL (e.g., http://127.0.0.1:8000).
  2. Now, open your web browser and visit the provided URL or http://localhost/new_project/public to see the default Laravel welcome page.
laravel on localhost

Congratulations! You have successfully installed Laravel on your local machine using XAMPP. You can now start developing your Laravel applications locally.

Conclusion

In conclusion, this step-by-step guide provided detailed instructions for installing Laravel on a local development environment using XAMPP. By setting up a local host server, developers can safely test and experiment with Laravel’s features, streamline their workflow, and work on multiple projects simultaneously without affecting live applications. After following the steps to install XAMPP, configure it properly, create a database using phpMyAdmin, install Composer, and finally install Laravel itself, developers will have a fully functional local Laravel environment. This local setup allows for efficient development, debugging, and testing before deploying applications to a production server. With Laravel installed locally, developers can exploit its powerful capabilities and conveniently explore its vast collection of features and tools on their own machines.

The Author

Anmol is a dedicated technical content writer known for her practical approach. She believes in experiencing processes firsthand before translating them into insightful content. Additionally, she is good at WordPress development and skills of digital forensics and cybersecurity. Beyond her professional endeavors, she enjoys playing sports games, particularly table tennis and badminton, valuing the balance between mental and physical agility.

Scroll to Top