How to Setup Laravel on Windows with Laragon

How to Setup Laravel on Windows with Laragon

A complete guide to setting up your Laravel development environment using Laragon on Windows.

Introduction

Laragon is a powerful development environment for Windows that makes it easy to set up and manage Laravel applications. This guide will walk you through the installation and configuration process.

Prerequisites

  • Windows 10 or higher
  • At least 4GB RAM
  • 20GB free disk space
  • Composer installed
  • Git installed

1 Install Laragon

Download and install Laragon:

# Download Laragon from https://laragon.org/download/
# Run the installer and follow the installation wizard

During installation, make sure to:

  • Select the "Full" installation option
  • Choose your preferred installation directory
  • Allow Laragon to add its bin directory to PATH

2 Configure PHP Version

Laragon allows you to switch between PHP versions:

# Right-click Laragon tray icon
# Go to PHP > Version
# Select PHP 8.1 or your preferred version

Verify PHP installation:

php -v

3 Create New Laravel Project

Create a new Laravel project using Composer:

cd C:\laragon\www
composer create-project laravel/laravel my-project

Or clone an existing project:

cd C:\laragon\www
git clone https://github.com/username/project.git

4 Configure Virtual Host

Laragon automatically creates virtual hosts. Access your site at:

http://my-project.test

Configure your .env file:

APP_NAME=MyProject
APP_ENV=local
APP_KEY=base64:your-key-here
APP_DEBUG=true
APP_URL=http://my-project.test

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_project
DB_USERNAME=root
DB_PASSWORD=

5 Install Dependencies

Install project dependencies:

cd my-project
composer install
npm install

Generate application key:

php artisan key:generate

Key Features Covered

  • Laragon installation and setup
  • PHP version management
  • Project creation and cloning
  • Virtual host configuration
  • Database setup
  • Dependency management

Best Practices

  • Keep Laragon updated
  • Use consistent PHP versions across projects
  • Regularly backup your projects
  • Use Git for version control
  • Configure proper file permissions

Common Issues

  • Port conflicts
  • PHP version mismatches
  • Virtual host not working
  • Database connection issues
  • Permission problems