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

Bug: Php from CLI is different from valet

Open kevyworks opened this issue 5 years ago • 3 comments

Basic info

Windows 10 Build WSL Distro WSL Verson PHP Version Valet version
19041.113 Ubuntu 18.4 1 7.4.3 1.0.5
  • [x] I've checked the issue queue and could not find anything similar to my bug.
  • [x] I'm on the latest version of valet-wsl (valet --version): <Valet-wsl-Version>
  • [x] I've run valet fix and valet install after updating and before submitting my issue/feature.

What is the problem? PHP from console/terminal is different or is using PHP 7.4.3. How do we instruct valet to use a specific php version which minimum is php version 7.2.

What was supposed to happen? Valet should use php7.4 instead of global or another best solution?

What actually happened? Nothing. Same PHP 7.4.3 on CLI

How to reproduce this? I just followed the Installation Guide at WIKI

What is the solution? Global change (currently breaks valet php >= 7.2)

$ sudo update-alternatives --set php /usr/bin/php7.1
$ php -v

Or you can use:

$ php7.1 -v

Sources N/A

Reference Stack Overflow

kevyworks avatar Feb 28 '20 16:02 kevyworks

Valet WSL does not determine what version of php to use. Your system configuration does. The nginx config proxies php request to 127.0.0.1:9000. Which ever version of php-fpm is configured to respond on that port is what is exposed to valet. If you have multiple versions of php you will need to make sure the correct version is being started and binding to that port.

valeryan avatar Feb 28 '20 18:02 valeryan

@valeryan Thanks for the reply, yes you are correct. Can I request when running the command $ valet use the script will also install the required php7.x-*? I wrote a Gist might also help some beginners as-well.

My problem right now is drvfs is very slow mounted from D: which is an SDCard. Compared to just using homestead somehow its faster, any hints on this?

By the way, I made a mistake; my WSL version is 2.

kevyworks avatar Feb 28 '20 21:02 kevyworks

@kevyworks I will have to check into this. Somethings are very limited on WSL in regards to how php-fpm is used. WSL does not currently support using sockets to talk to services. That is why the nginx config in the version of valet points to 127.0.0.1:9000 and the wiki have you install all the dependencies beforehand versus letting valet install them for you. I will look at the use command and see if I can make it work. Probably by binding a separate copy of fpm to a different port that is dedicated to valet so that the use statement does not have to worry about turning off system-level fpm.

valeryan avatar Mar 02 '20 18:03 valeryan