You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

添加vladimir-yuldashev/laravel-queue-rabbitmq库后执行composer install出现PHP版本依赖错误求助

解决Composer提示PHP版本不匹配但实际版本满足的问题

Hey there, let's dig into why you're seeing that frustrating PHP version error even though your server is running PHP 8.1.3. The culprit here is almost definitely the vladimir-yuldashev/laravel-queue-rabbitmq package you just added—here's what's going on and how to fix it:

问题根源

You've set the rabbitmq package version to * in your composer.json, which tells Composer to grab the latest available release. The most recent versions of this package require PHP 8.1 or higher, but your project's root PHP constraint is still ^7.3|^8.0. Even though your actual PHP version meets the requirement, Composer enforces that all dependency constraints align with the project's base requirements, hence the error.

解决方案1:升级项目的PHP版本约束

Since you're already running PHP 8.1.3 on your server, the cleanest fix is to update your project's PHP requirement to match what the rabbitmq package needs. Edit your composer.json's require section:

"php": "^8.1",

Then run this command to refresh your dependencies:

composer install

解决方案2:锁定rabbitmq包到兼容版本

If you can't upgrade your project's PHP constraint right now, you can specify an older version of the rabbitmq package that works with PHP 8.0. The v13.x branch of this package supports PHP 8.0, so update your composer.json like this:

"vladimir-yuldashev/laravel-queue-rabbitmq": "^13.0",

Then run this to install the compatible version:

composer update vladimir-yuldashev/laravel-queue-rabbitmq

额外需要确认的点

  • Double-check that the PHP CLI version you're using for composer install matches your server's PHP version! Sometimes the web server's PHP version and the command-line PHP version can differ—run php -v in your terminal to verify you're using PHP 8.1.3.
  • If you're using a containerized environment like Laravel Sail, make sure the container's PHP version matches what you need (8.1+ for solution 1, 8.0 for solution 2).

内容的提问来源于stack exchange,提问作者Michał Kucharzyk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 19:57:50