valet-windows icon indicating copy to clipboard operation
valet-windows copied to clipboard

feat: add support for multiple PHP services

Open iamroi opened this issue 2 years ago • 16 comments

Hey! Amazing work on the package <3

Currently it's missing the multiple PHP versions management and the valet use command is disabled.

This PR adds below new commands and enables valet use to switch between PHP versions.

php:add            Add PHP by specifying a path
php:install        Reinstall all PHP services from [valet php:list]
php:list           List all PHP services
php:remove         Remove PHP by specifying a path
php:uninstall      Uninstall all PHP services from [valet php:list]

use                Change the version of PHP used by valet

Examples: valet php:add "c:\php-7.3.29" valet php:remove "c:\php-8.1.2" valet use 8.0.15

$ valet php:list
Listing PHP services...
+---------+---------------+------+-------------+---------+
| Version | Path          | Port | xDebug Port | Default |
+---------+---------------+------+-------------+---------+
| 8.0.15  | C:\php-8.0.15 | 9001 | 9101        |         |
| 8.1.2   | C:\php-8.1.2  | 9002 | 9102        |         |
| 7.4.27  | C:\php-7.4.27 | 9004 | 9104        |         |
| 7.3.29  | C:\php-7.3.29 | 9005 | 9105        | X       |
+---------+---------------+------+-------------+---------+

Also added a feature to enable an individual site to use a specific PHP version similar to this original Valet package PR https://github.com/laravel/valet/pull/1192

Example: valet use "8.1.2" --site="foo"

iamroi avatar Mar 05 '22 16:03 iamroi

Thanks! I'll check it latter in the week.

cretueusebiu avatar Mar 07 '22 09:03 cretueusebiu

@cretueusebiu any news on this eagerly awaited PR?

damsfx avatar May 04 '22 23:05 damsfx

@cretueusebiu Any update on this PR?

lekeabiodun avatar Jun 06 '22 10:06 lekeabiodun

I really awaiting this massy update which will allow me to run multiple php version for each project. @cretueusebiu are this PR going to be merged or you are planning to use the official valet v3?

muath-ye avatar Jun 09 '22 17:06 muath-ye

@muath-ye It's been a while since I've worked on Valet... For me it worked great so far so that's why I didn't make any updates.

Also these kind of changes require a bit of manual testing both on win 8 and 10.

I'll try to take a look this weekend at both the PR and the official Valet. 🤞

cretueusebiu avatar Jun 09 '22 17:06 cretueusebiu

It becomes quite urgent for me to have different versions of PHP for each project.

@iamroi What would be the best way to use your PR as a replacement?

damsfx avatar Jun 15 '22 14:06 damsfx

Hi @damsfx you can tell composer to use the forked repository. This might help - https://stackoverflow.com/questions/13498519/how-to-require-a-fork-with-composer

Please note that I still need to do thorough testing to make sure everything works as expected.

@cretueusebiu I'm hoping to add some tests this weekend.

iamroi avatar Jun 22 '22 00:06 iamroi

Hey @damsfx Please beware of the below

Currently, if you miss the double quotes from this command or any other similar command for eg. valet php:add "c:\php-7.3.29", I think it still runs but stores wrong data in the config. This needs to be resolved.

iamroi avatar Jun 22 '22 00:06 iamroi

Hi @damsfx you can tell composer to use the forked repository. This might help - https://stackoverflow.com/questions/13498519/how-to-require-a-fork-with-composer

Please note that I still need to do thorough testing to make sure everything works as expected.

@cretueusebiu I'm hoping to add some tests this weekend.

Yes, I found the solution some time ago:

{
    "require": {
         ...
        "cretueusebiu/valet-windows": "dev-master"
    },
    "repositories": [
        {
            "type": "git",
            "url": "[email protected]:iamroi/valet-windows.git"
        }
    ]
}

I have made some tests ... and suggested you a PR to add PHP version in links table letting us know which version each site is running.
https://github.com/iamroi/valet-windows/pull/1

Too busy at the moment to resume testing, but I will try.

damsfx avatar Jun 22 '22 16:06 damsfx

Hi @cretueusebiu , any update on this feature?

ricky-rebo avatar Sep 22 '22 07:09 ricky-rebo

Hi @cretueusebiu , any update on this feature?

@cretueusebiu Bump !

damsfx avatar Jan 19 '23 15:01 damsfx

this feature held me back to switch from laragon

meorajrul avatar Feb 02 '23 11:02 meorajrul

Hi there! I've install the valet version 2.5, and try to use the command valet php:add "C:\xampp\php81" , but it shows There are no commands defined in the "php" namespace. . Did I miss something? Thanks in advance.

Terrychang0337 avatar Feb 19 '23 02:02 Terrychang0337

@cretueusebiu any possible ETA to have this PR merged, this feature is eagerly required by majority dev's

RohanSakhale avatar Mar 17 '23 05:03 RohanSakhale

Hi @damsfx you can tell composer to use the forked repository. This might help - https://stackoverflow.com/questions/13498519/how-to-require-a-fork-with-composer Please note that I still need to do thorough testing to make sure everything works as expected. @cretueusebiu I'm hoping to add some tests this weekend.

Yes, I found the solution some time ago:

{
    "require": {
         ...
        "cretueusebiu/valet-windows": "dev-master"
    },
    "repositories": [
        {
            "type": "git",
            "url": "[email protected]:iamroi/valet-windows.git"
        }
    ]
}

Hi @damsfx . Can you tell me where you've added this please? Is it per project basis (in project's composer.json), or in the global installation of cretueusebiu/valet-windows composer.json?

@cretueusebiu This is a very much needed requirement for developers. This pr has the backing of a multitude of people and should be merged asap. I love the valet windows port but it is muchly lacking in this php version switch mechanic.

yCodeTech avatar Apr 14 '23 22:04 yCodeTech

Hi @damsfx you can tell composer to use the forked repository. This might help - https://stackoverflow.com/questions/13498519/how-to-require-a-fork-with-composer Please note that I still need to do thorough testing to make sure everything works as expected. @cretueusebiu I'm hoping to add some tests this weekend.

Yes, I found the solution some time ago:

{
    "require": {
         ...
        "cretueusebiu/valet-windows": "dev-master"
    },
    "repositories": [
        {
            "type": "git",
            "url": "[email protected]:iamroi/valet-windows.git"
        }
    ]
}

Hi @damsfx . Can you tell me where you've added this please? Is it per project basis (in project's composer.json), or in the global installation of cretueusebiu/valet-windows composer.json?

@cretueusebiu This is a very much needed requirement for developers. This pr has the backing of a multitude of people and should be merged asap. I love the valet windows port but it is muchly lacking in this php version switch mechanic.

@yCodeTech you need to update the global composer file, usually located at C:\Users(your user)\AppData\Roaming\Composer

and then simply run composer global require cretueusebiu/valet-windows:dev-master to sync

harshitpeer avatar Apr 21 '23 16:04 harshitpeer