Different PHP version per project


  • | 48 points

    Hi,

    Is there any way I can set up a different PHP version per project? I have actually installed 7.2 and 7.1 but I want a project uses 7.1 and the other ones 7.2.

    Any ideas?

    Thanks in advance


  • | 2594 points

    @poxxac Indeed this would be helpful. I find I'm needing older php versions to work on client sites that require older versions which I will then repair and then upgrade and push live.


  • | 4834 points

    @poxxac Leokhoa answered a similar question here: https://forum.laragon.org/topic/805/a-specific-php-version-for-selected-virtual-hosts/2

    I am also looking into the apachelounge forums as there is some info there on using Apache modules (fcgi) to allow different PHP version per virtual host:

    https://www.apachelounge.com/viewtopic.php?t=6615

    However, the forum post is old and I am unsure if the suggestions work in a Windows context but it may be a starting point.


  • | 289 points

    This is the only thing that makes me miss Laravel Homestead so much.


  • administrators
    | 131330 points

    @Christhofernatalius : You can install another Laragon to other folder.


  • | 289 points

    @leokhoa But then if I have projects with php 5.4, 5.5, 5.6, 7.0, 7.1, 7.2 I have to install 6 Laragon instances?
    That is impractical IMHO.

    Anyway I'm quite happy with Laragon aside from this limitation.


  • administrators
    | 131330 points

    @Christhofernatalius : No, you don't need to have 6 Laragon instances. You just need to switch the PHP version you want to work with (Menu > PHP > Version).

    Adding another PHP version to Laragon is very easy and lightweight:
    https://forum.laragon.org/topic/166/tutorial-how-to-add-another-php-version

    With Laragon 4.0, you can add many php download links to Menu > Tools > Quick add > Configuration and may the adding PHP version even easier (and can be re-used when you have new machine):

    php7.3=https://windows.php.net/downloads/qa/php-7.3.0RC6-Win32-VC15-x64.zip
    php7.2=https://windows.php.net/downloads/releases/php-7.2.12-Win32-VC15-x64.zip
    ....
    php5.4=...
    

    Each of them just takes ~ 25MB and doesn't consume your resources.
    With Homestead, you have many fat (~ 1GB) VMs running consuming your resources.


  • | 242 points

    Old topic but my answer may be useful for someone. it's possible. in my example I use an extra PHP 7.3 for one project, despite the fact that Laragon has set PHP 7.4 for other projects.

    1. Create procfile for new php fastcgi process (Menu -> Laragon -> Procfile):
    PHP 73 FastCGI: "php-cgi.exe -b 127.0.0.1:9123" PWD=C:\laragon\bin\php\php-7.3.17-nts-Win32-VC15-x64
    
    1. Edit vHost for specific project and remove "auto" prefix from name:
      location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass   127.0.0.1:9123;
        #fastcgi_pass unix:/run/php/php7.3-fpm.sock;
      }
    
    1. After start nginx, Menu -> Laragon -> run process at top, in my case "PHP 73 FastCGI"

    2. Viola!

    alt text

    Maybe someone knows, how to set the autorun this process after start/reload Nginx? Autorun in Procfile runs this process when Laragon starts, but later start or reload Nginx resets all PHP processes.


  • | 657 points

    I've just come across this topic now, wanting to switch.
    I know it's an old topic, but my two cents is that I tried the solution by @leokhoa and the Quick add Configuration didn't work.
    However, the link they posted does work.

    I will give @N1ebieski's solution a go at some point and see if that helps (it would be nice to have it per-project).

    I've seen hosting providers do it, yet I am unable to set it up for myself (either on Ubuntu or Laragon).


  • | 40 points

    start with php 7.1 and change php version to 7.2.
    but dont restart both nginx & apache.
    just reload nginx. now apache work with 7.1 and nginx work with php 7.2.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.