Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for multiple PHP services #195

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

iamroi
Copy link

@iamroi iamroi commented Mar 5, 2022

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 laravel#1192

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

@cretueusebiu
Copy link
Owner

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

@damsfx
Copy link

damsfx commented May 4, 2022

@cretueusebiu any news on this eagerly awaited PR?

@lekeabiodun
Copy link

@cretueusebiu Any update on this PR?

@muath-ye
Copy link

muath-ye commented Jun 9, 2022

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 muath-ye mentioned this pull request Jun 9, 2022
@cretueusebiu
Copy link
Owner

@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
Copy link

damsfx commented Jun 15, 2022

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
Copy link
Author

iamroi commented Jun 22, 2022

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
Copy link
Author

iamroi commented Jun 22, 2022

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
Copy link

damsfx commented Jun 22, 2022

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.
iamroi#1

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

*/
$app->command('php:add [path]', function ($path) {
info("Adding {$path}...");

Copy link
Author

@iamroi iamroi Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamroi TODO check if the $path is valid before proceeding

@ricky-rebo
Copy link

Hi @cretueusebiu , any update on this feature?

@damsfx
Copy link

damsfx commented Jan 19, 2023

Hi @cretueusebiu , any update on this feature?

@cretueusebiu Bump !

@meorajrul
Copy link

this feature held me back to switch from laragon

@Terrychang0337
Copy link

Terrychang0337 commented Feb 19, 2023

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
Copy link

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

@yCodeTech
Copy link

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.

@harshitpeer
Copy link

harshitpeer commented Apr 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.