phpro / grumphp

A PHP code-quality tool
MIT License
4.11k stars 429 forks source link

Support multiple php versions for tasks #1125

Closed pelletiermaxime closed 3 months ago

pelletiermaxime commented 4 months ago
Q A
Version 2.5.0
Bug? no
New feature? yes
Question? no
Documentation? no

Hello, we use multiple php versions installer either locally or into a docker container for our projects. So we have project A that uses php 7.4, project B with 8.1 and project C with 8.3. All these projects have different versions of php-cs-fixer/phpstan/etc for their particular versions. We then run 'php7.4 vendor/bin/phpstan' for project A, 'php8.1 vendor/bin/phpstan' for project B, etc. The problem with grumphp is that there doesn't seem to have a way to prepend something before commands. Afaik it just runs 'vendor/bin/phpstan analyse'. Is an option to add a specific php executable before commands something possible to do ? Thanks, we all love grumphp!

veewee commented 4 months ago

Hello,

Thanks for reaching out. That is indeed correct : we don't do any PHP-executable selection in here. It is not impossible to do so, but it will take a lot of time to implement for something that seems more like an infrastructural problem to me. So I guess i'll probably reject a PR that introduces this level of complexity at this point.

Another way around this could be to link the PHP correct PHP version before running GrumPHP or to spin up the correctly versioned PHP containers per project. That way you don't have to care anymore about it being 8.1 or 8.2. Just some ideas thrown in the void :)

pelletiermaxime commented 3 months ago

Yeah for sure, those are good workaround the problem. As you might guess, our project is pretty huge, so spinning up docker containers, especially when we have some mac users, is not as easy as it seems. I will probably look into switching the php symbolic link before running grumphp and make it work for now. Thanks for looking into it!