0

Similar/same as: Your Composer dependencies require a PHP version ">= 8.1.0"

I'm using wsl. I've installed php8.1 using

sudo apt install php8.1 libapache2-mod-php8.1

...and I've uninstalled all versions of php except for 8.1 using:

sudo apt remove php8.0

...etc. I've then run:

update-alternatives --set php /usr/bin/php8.1
update-alternatives --set phar /usr/bin/phar8.1
update-alternatives --set phar.phar /usr/bin/phar.phar8.1
service apache2 restart

...and I've restarted wsl and yet, when I attempt to start sail:

./vendor/bin/sail up

I'm still getting the error:

Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.14.

Now then,

php -v

gives:

PHP 8.1.8 (cli) (built: Jul 11 2022 08:29:57) (NTS)

...and I've absolutely no idea where

You are running 8.0.14. 

...is coming from! I think I've tried everything I can find to resolve this (except for overriding composer platform requirements - but something I'm using is expecting php8.1, so I don't really want to change it!)

Any help greatly appreciated

A.

A D
  • 1
  • 2
  • It might be same problem as is in [this question](https://stackoverflow.com/questions/71081381/laravel-sail-installing-wrong-php-version). Did you try to update Sail? It [has been fixed](https://github.com/laravel/sail/commit/dbe4a908d254d91f99ed89047c9eec4bae8973b0) since Jan 20. – Jax-p Jul 20 '22 at 13:02
  • `./vendor/bin/sail up` uses the docker-compose file, how does yours look? – John Zwarthoed Jul 20 '22 at 13:24
  • What does `dpkg -l | grep php8` tell you? Maybe there are more PHP 8.0 packages installed? – Nico Haase Jul 20 '22 at 17:26
  • Ah! Right, ok, so I'm thick! I updated docker-compose.yml so that: ``` context: ./vendor/laravel/sail/runtimes/8.1 ``` and ``` image: sail-8.1/app ``` ...which appears to have solved the PHP error. However, I cannot access my app at localhost (I get the apache default page) Where do I go next?! – A D Jul 20 '22 at 17:27
  • That depends. Why do you use `apt` when running stuff in a Docker container? Why not properly update that container instead? – Nico Haase Jul 20 '22 at 17:40
  • yeh, cos I'm stupid - I was doing apt remove on local, not docker! – A D Jul 20 '22 at 18:13

1 Answers1

0

Thanks to @jax-p for pointing me in the right direction and this helpful article!:

I updated docker-compose.yml so that:

context: ./vendor/laravel/sail/runtimes/8.1 

and

image: sail-8.1/app 

then ran:

./vendor/bin/sail build --no-cache

...which appears to have solved the PHP error.

A D
  • 1
  • 2