Composer detects wrong php version I have php 7.3 installed. It is correctly detected by terminal and in artisan:
mathewparet$ php -v
PHP 7.3.25 (cli) (built: Nov 30 2020 14:36:22) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.25, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.25, Copyright (c) 1999-2018, by Zend Technologies
mathewparet$
mathewparet$ php artisan tinker
Psy Shell v0.10.4 (PHP 7.3.25 — cli) by Justin Hileman
>>> PHP_VERSION_ID
=> 70325
>>> PHP_VERSION
=> "7.3.25"
>>> exit
Exit: Goodbye
mathewparet$
But when calling the website over the browser I get:
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0". You are running 7.2.34. in /Users/mathewparet/Projects/vpn/vendor/composer/platform_check.php on line 24
I am running on Mac BigSur + Valet
If you check the version from console, that is running the php CLI. Check the base php version that your server/apache/nginx is setup to use. Usually there are folders for cli apache2 fpm .
Thanks for the pointer.
I checked the valet NGINX config
server {
listen 127.0.0.1:80;
server_name vpn.test www.vpn.test *.vpn.test;
return 301 https://$host$request_uri;
}
server {
listen 127.0.0.1:443 ssl http2;
server_name vpn.test www.vpn.test *.vpn.test;
root /;
charset utf-8;
client_max_body_size 512M;
http2_push_preload on;
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
internal;
alias /;
try_files $uri $uri/;
}
ssl_certificate "/Users/mathewparet/.config/valet/Certificates/vpn.test.crt";
ssl_certificate_key "/Users/mathewparet/.config/valet/Certificates/vpn.test.key";
location / {
rewrite ^ "/Users/mathewparet/.composer/vendor/laravel/valet/server.php" last;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log "/Users/mathewparet/.config/valet/Log/nginx-error.log";
error_page 404 "/Users/mathewparet/.composer/vendor/laravel/valet/server.php";
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass "unix:/Users/mathewparet/.config/valet/valet.sock";
fastcgi_index "/Users/mathewparet/.composer/vendor/laravel/valet/server.php";
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME "/Users/mathewparet/.composer/vendor/laravel/valet/server.php";
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.ht {
deny all;
}
}
server {
listen 127.0.0.1:60;
server_name vpn.test www.vpn.test *.vpn.test;
root /;
charset utf-8;
client_max_body_size 128M;
add_header X-Robots-Tag 'noindex, nofollow, nosnippet, noarchive';
location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
internal;
alias /;
try_files $uri $uri/;
}
location / {
rewrite ^ "/Users/mathewparet/.composer/vendor/laravel/valet/server.php" last;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log "/Users/mathewparet/.config/valet/Log/nginx-error.log";
error_page 404 "/Users/mathewparet/.composer/vendor/laravel/valet/server.php";
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass "unix:/Users/mathewparet/.config/valet/valet.sock";
fastcgi_index "/Users/mathewparet/.composer/vendor/laravel/valet/server.php";
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME "/Users/mathewparet/.composer/vendor/laravel/valet/server.php";
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.ht {
deny all;
}
}
This is what it uses for PHP:
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass "unix:/Users/mathewparet/.config/valet/valet.sock";
fastcgi_index "/Users/mathewparet/.composer/vendor/laravel/valet/server.php";
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME "/Users/mathewparet/.composer/vendor/laravel/valet/server.php";
fastcgi_param PATH_INFO $fastcgi_path_info;
}
I don't know where to go from here.
Ha ha a system restart fixed the issue :)
For those whose issue isn't resolved by restarting, you can force valet to re-link a given php version by running:
valet use [email protected] --force
The force flag will re-link and re-configure the current php version used by valet (assuming the current version 8.1 in this example).
Please sign in or create an account to participate in this conversation.