cretueusebiu / valet-windows

Laravel Valet for Windows.
MIT License
912 stars 86 forks source link

feat: add support for multiple PHP services #195

Open iamroi opened 2 years ago

iamroi commented 2 years ago

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"

cretueusebiu commented 2 years ago

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

damsfx commented 2 years ago

@cretueusebiu any news on this eagerly awaited PR?

lekeabiodun commented 2 years ago

@cretueusebiu Any update on this PR?

muath-ye commented 2 years ago

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?

cretueusebiu commented 2 years ago

@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. 🤞

damsfx commented 2 years ago

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?

iamroi commented 2 years ago

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 commented 2 years ago

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.

damsfx commented 2 years ago

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": "git@github.com: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.

ricky-rebo commented 2 years ago

Hi @cretueusebiu , any update on this feature?

damsfx commented 1 year ago

Hi @cretueusebiu , any update on this feature?

@cretueusebiu Bump !

meorajrul commented 1 year ago

this feature held me back to switch from laragon

Terrychang0337 commented 1 year ago

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.

RohanSakhale commented 1 year ago

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

yCodeTech commented 1 year ago

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": "git@github.com: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.

harshitpeer commented 1 year ago

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": "git@github.com: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