DEV Community

Yogesh Galav
Yogesh Galav

Posted on • Edited on

How to use different version of laravel in windows?

You can run Laravel using 3 ways

  1. Artisan commands
  2. Docker
  3. Using Xampp/wampp
  4. Using Laragon

The most common way for local development is php artisan for that you need only correct version of php.

The best way to run multiple version of php is changing them in environment variable.
For example I have two xampp folders, xampp81 and xampp74 which I only use for php folder. Don't run apache on any of them, "php artisan serve" will alone do the job.

hence when I run laravel 8 or 9 I change the environment variable to C://xampp81/php
and when I run laravel 6 or 7 I change the environment variable to C://xampp74/php

Second way is docker.
On docker you could run any image nginix, apache, php-fpm.
The problem with docker I feel is you require more ram and processing, and also there's little extra effort needed for running laravel 9 with vite.
On docker you can also use artisan image directly
Or you can use my repo to run different versions, Just change the env file and enjoy
https://github.com/yogeshgalav/dompp
If you are new to docker I also have blog explaining this repo as well, Check here .

Third way is to use Xampp.
If you use Xampp run apache server of xampp81 and xampp74 on different ports.
For example let xampp81, apache run on port 80 and change the port of xampp74, apache to 8081
For this you need to change port 80 to 8081 in xampp74/apache/httpd.conf and xampp74/apache/httpd-ssl.conf files.
However I found that most of the time xampp apache or mysql gives error that are resolvable but through tedious process.

Best way is to use Laragon.
My new preference is Laragon, I heard about it late hence editing this post and writing about it, it's the best in performance, DX, version switching and no more xampp like errors. it also provides folder based url like laravelApp.test which can be accessed directly without running any artisan command.

You can also automate the task of running same npm or similar commands by using vscode extension: Restore Terminal

I hope you enjoyed reading this.
Please give your love and support to my Github open source repositories.

Thank You and Have Nice Day!

Top comments (0)