Complete Guide to Installing Laravel 12 on Windows
Step-by-Step Installation Guide with Detailed Commands and Troubleshooting Tips
Laravel continues to be one of the most popular PHP frameworks for web development, and with the release of Laravel 12, developers have access to even more powerful features and improvements. Installing Laravel 12 on Windows requires some setup, but with this comprehensive guide, you’ll be up and running in no time.
Prerequisites for Laravel 12 Installation
Essential Requirements Before Installing Laravel 12
Before installing Laravel 12, ensure your Windows system meets these requirements:
System Requirements
- PHP: Version 8.2 or higher
- Composer: Latest version
- Web Server: Apache or Nginx (optional for development)
- Database: MySQL 5.7+, PostgreSQL, or SQLite
- Node.js & NPM: Required for frontend assets
Step 1: Install PHP on Windows
Setting Up PHP 8.2+ on Your Windows Machine
Method 1: Using XAMPP/WAMP
- Download XAMPP from apachefriends.org
- Install XAMPP with PHP 8.2+
- Add PHP to your system PATH
Method 2: Manual PHP Installation
Download PHP from the official Windows downloads page:
PHP Installation Commands
# Download PHP from: https://windows.php.net/download/ # Choose the Thread Safe version for XAMPP, Non-Thread Safe for IIS # Extract PHP to C:\php # Add PHP to System PATH: 1. Right-click on 'This PC' → Properties → Advanced system settings 2. Click 'Environment Variables' 3. Under 'System variables', find 'Path' and click 'Edit' 4. Click 'New' and add 'C:\php' 5. Click OK to save all changes # Verify PHP installation in Command Prompt: php --version
Configure PHP for Laravel
php.ini Configuration
# Copy php.ini-development to php.ini: copy C:\php\php.ini-development C:\php\php.ini # Edit php.ini and enable these extensions (remove semicolon): extension=curl extension=fileinfo extension=mbstring extension=openssl extension=pdo_mysql extension=tokenizer extension=xml # Set required memory limit: memory_limit = 512M max_execution_time = 300 # For file uploads (if needed): upload_max_filesize = 100M post_max_size = 100M
Step 2: Install Composer
PHP Dependency Manager Installation
Composer Installation Steps
# Method 1: Using Composer-Setup.exe (Recommended) 1. Download Composer-Setup.exe from: https://getcomposer.org/download/ 2. Run the installer and follow these steps: - Select "Install for all users" - Browse to your PHP installation (C:\php) - Check "Add to PATH" - Click Install # Method 2: Manual Installation php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');" # Move composer.phar to make it globally accessible: move composer.phar C:\php\composer.phar # Create a batch file (composer.bat) in C:\php: @php "%~dp0composer.phar" %* # Verify Composer installation: composer --version
Step 3: Install Node.js and NPM
For Frontend Asset Management
Node.js Installation
# 1. Download Node.js installer from: https://nodejs.org/ # 2. Choose the LTS version (Long Term Support) # 3. Run the installer with these options: - Accept license agreement - Choose installation path (default: C:\Program Files\nodejs) - Select "Add to PATH" - Click Install # 4. Verify installation in Command Prompt: node --version npm --version # 5. Update npm to latest version: npm install -g npm@latest # 6. Install additional tools (optional but recommended): npm install -g yarn npm install -g @vue/cli
Step 4: Install Laravel 12
Creating Your First Laravel 12 Application
Method 1: Using Laravel Installer (Recommended)
Laravel Installer Method
# Install Laravel Installer globally: composer global require laravel/installer # Add Composer's global bin directory to PATH: 1. Find Composer's global directory: composer global config bin-dir --absolute # Typical path: C:\Users\[YourUsername]\AppData\Roaming\Composer\vendor\bin 2. Add this path to System PATH (same as PHP) # Create a new Laravel 12 project: laravel new my-laravel-app # Or specify Laravel 12 explicitly: laravel new my-laravel-app --version=^12.0 # Navigate to your project directory: cd my-laravel-app
Method 2: Using Composer Create-Project
Composer Create-Project Method
# Create Laravel 12 project using Composer: composer create-project laravel/laravel my-laravel-app ^12.0 # Or for the latest version: composer create-project --prefer-dist laravel/laravel my-laravel-app # Navigate to project directory: cd my-laravel-app # Install PHP dependencies: composer install # Install Node.js dependencies: npm install
Step 5: Configure Environment
Setting Up Your Laravel Application
Generate Application Key
Environment Configuration
# Copy .env.example to .env: copy .env.example .env # Generate application key: php artisan key:generate # Configure database in .env file: DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_db DB_USERNAME=root DB_PASSWORD= # For SQLite (simpler for development): DB_CONNECTION=sqlite DB_DATABASE=database/database.sqlite # Create SQLite database file: mkdir database type nul > database/database.sqlite
Run Database Migrations
Database Setup Commands
# Run database migrations: php artisan migrate # Or with seed data: php artisan migrate --seed # Create symbolic link for storage (if needed): php artisan storage:link # Clear configuration cache: php artisan config:clear php artisan cache:clear php artisan view:clear
Step 6: Serve Laravel Application
Running Your Laravel 12 Project
Method 1: Laravel Development Server
Development Server Commands
# Start Laravel development server: php artisan serve # Specify host and port: php artisan serve --host=127.0.0.1 --port=8000 # Run on all network interfaces (for mobile testing): php artisan serve --host=0.0.0.0 --port=8000 # Output will show: Starting Laravel development server: http://127.0.0.1:8000 Press Ctrl+C to stop the server # In a separate terminal, compile frontend assets: npm run dev # For production build: npm run build
Method 2: Using XAMPP/WAMP
XAMPP/WAMP Configuration
# 1. Move your Laravel project to XAMPP htdocs: C:\xampp\htdocs\my-laravel-app # 2. Configure virtual host in XAMPP: # Edit C:\xampp\apache\conf\extra\httpd-vhosts.conf <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/my-laravel-app/public" ServerName laravel12.test <Directory "C:/xampp/htdocs/my-laravel-app/public"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost> # 3. Add to Windows hosts file (C:\Windows\System32\drivers\etc\hosts): 127.0.0.1 laravel12.test # 4. Restart Apache from XAMPP Control Panel # 5. Access your site at: http://laravel12.test
Step 7: Verify Installation
Testing Your Laravel 12 Setup
Verification Commands
# Check Laravel version: php artisan --version # Should output: Laravel Framework 12.x.x # Run Laravel's built-in tests: php artisan test # Check application status: php artisan about # Verify all services are working: php artisan inspire # Create a test route to verify: # Add to routes/web.php Route::get('/test', function () { return response()->json([ 'message' => 'Laravel 12 is working!', 'version' => app()->version(), 'timestamp' => now(), ]); }); # Visit: http://127.0.0.1:8000/test
Troubleshooting Common Issues
Solving Installation Problems on Windows
Common Problems and Solutions
- PHP not recognized in CMD: Add PHP to System PATH and restart terminal
- Composer memory limit error: Increase memory_limit in php.ini to 512M or 1024M
- Permission denied errors: Run terminal as Administrator
- Port 8000 already in use: Use different port:
php artisan serve --port=8080 - SQLite not working: Enable sqlite3 extension in php.ini
- Node.js not found: Reinstall Node.js and check “Add to PATH”
- SSL certificate problem: Run:
composer config --global disable-tls true
Debug Commands
Debugging Commands
# Check PHP configuration: php --ini php -m # Check Composer diagnostics: composer diagnose # Clear all Laravel caches: php artisan optimize:clear # Check storage permissions: icacls storage /grant Users:(OI)(CI)F /T icacls bootstrap/cache /grant Users:(OI)(CI)F /T # Update all dependencies: composer update npm update # Check for Windows-specific issues: echo %PATH% where php where composer where node
Conclusion
You’ve Successfully Installed Laravel 12 on Windows!
Congratulations! You’ve successfully installed Laravel 12 on your Windows machine. You now have a fully functional Laravel development environment ready for building modern web applications.
Next Steps:
- Explore Laravel’s documentation at laravel.com/docs
- Try installing Laravel Breeze for authentication:
composer require laravel/breeze --dev - Learn about Laravel’s new features in version 12
- Start building your first Laravel 12 application
Remember: Laravel 12 brings exciting new features and improvements. Keep your development environment updated and explore the latest capabilities of this powerful PHP framework!
Laravel 12 requires PHP 8.2 or higher, Composer, and a supported database (MySQL 5.7+, PostgreSQL, or SQLite). Node.js and NPM are recommended for frontend asset management.
No, Composer is essential for Laravel installation as it manages PHP dependencies. You must install Composer before installing Laravel 12.
Use a different port: <code>php artisan serve –port=8080</code> or find and stop the process using port 8000 with: <code>netstat -ano | findstr :8000</code> then <code>taskkill /PID [PID] /F</code>
Run <code>php artisan key:generate</code> to generate an application key. Ensure your .env file exists and is properly configured.
Yes! Laravel 12 works perfectly with XAMPP. Place your Laravel project in the htdocs folder and configure a virtual host for better development experience.

Leave a Reply