尝试使用 composer 安装 laravel 时 php 版本出错

Posted

技术标签:

【中文标题】尝试使用 composer 安装 laravel 时 php 版本出错【英文标题】:Error with php version when trying to install laravel with composer 【发布时间】:2015-12-22 17:47:33 【问题描述】:

所以,现在已经两天了,我一直在努力在我的旧 mac 10.6 上安装 laravel 我的电脑运行 php 5.5.27

但由于某种原因,当我在终端中使用此代码时:

composer create-project laravel/laravel project-name ~4.2.0 --prefer-dist

我明白了:

- laravel/framework v4.2.9 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.8 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.7 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.6 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.5 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.4 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.3 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.2 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.17 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.16 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.15 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.14 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.13 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.12 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.11 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.10 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.1 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - laravel/framework v4.2.0 requires php >=5.4.0 -> your PHP version (5.3.26) or "config.platform.php" value does not satisfy that requirement. - Installation request for laravel/framework 4.2.* -> satisfiable by laravel/framework[v4.2.0, v4.2.1, v4.2.10, v4.2.11, v4.2.12, v4.2.13, v4.2.14, v4.2.15, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].

Your requirements could not be resolved to an installable set of packages.

有人知道为什么 laravel 不能识别我的 php 版本吗?

【问题讨论】:

【参考方案1】:

显然,您的机器上安装了几个 PHP。 使用以下 shell 命令检查 PATH 环境中的第一个 php。

哪个php

【讨论】:

好的,所以我在终端中写了 php -i 并得到了phpinfo() PHP Version => 5.3.26 但是当我执行 phpinfo();在我的一个 .php 文件中,在浏览器上显示为 5.5.27.. 我不明白 检查您的 nginx 或 apache 配置以确认您使用的是哪个 php-fpm。另外,使用 ps 来查看哪个 php-fpm 正在运行。 谢谢,但我该怎么做呢?我对终端命令不太熟悉。

以上是关于尝试使用 composer 安装 laravel 时 php 版本出错的主要内容,如果未能解决你的问题,请参考以下文章

尝试使用 composer 安装 laravel 时 php 版本出错

Laravel 5.2 - 使用 composer 和 git bash 安装 laravel 时出错

为 Laravel 安装 composer 时缺少 composer.json 文件

laravel 在窗口 7 的 xampp 中与 composer 一起安装

尝试在 Laravel 项目上构建 docker compose 时不受支持的选项

尝试在laravel 5.1 mac上安装php phantom js时,Composer安装错误