简体   繁体   English

PHP:Composer 使用比使用版本旧的 PHP 版本(在共享主机上)

[英]PHP: Composer uses PHP version older than the used version (on shared hosting)

I'm trying to run composer commands from the SSH terminal but I get this我正在尝试从 SSH 终端运行作曲家命令,但我明白了

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.33". You are running 7.1.33.

when I run php -v I get PHP 7.3.33 (cli) and when I run phpinfo() in Laravel (not the terminal) I get PHP Version 7.3.33 when I run php -v I get PHP 7.3.33 (cli) and when I run phpinfo() in Laravel (not the terminal) I get PHP Version 7.3.33

In composer.json:在 composer.json 中:

"require": {
    "php": "^7.3.33",

In .htaccess在 .htaccess

<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>

Why does this happen and how can I fix it?为什么会发生这种情况,我该如何解决?

Note that .htaccess only affects the Apache configuration.请注意, .htaccess仅影响 Apache 配置。 When accessing the server via SSH the file is completely ignored/useless.通过 SSH 访问服务器时,该文件被完全忽略/无用。

Some providers install multiple versions of PHP, making it available by typing php7.3 , and the php is a simple alias to the current default version.一些提供商安装了多个版本的 PHP,通过键入php7.3使其可用,并且php是当前默认版本的简单别名。 Probably the composer is set up in a way to use a different version of the default (not sure how/why) while your ssh session is using another.可能作曲家设置为使用不同版本的默认值(不确定如何/为什么),而您的 ssh session 正在使用另一个版本。

Since your php -v is reporting the desired version.由于您的php -v正在报告所需的版本。 I would suggest downloading composer.phar and running it locally via php composer.phar... instead of relying on the currently systemwide installed composer.我建议下载composer.phar并通过php composer.phar...而不是依赖当前系统范围内安装的 composer。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM