如何告诉作曲家忽略特定软件包的php版本?

时间:2018-06-26 18:01:01

标签: composer-php

我似乎无法安装软件包,因为我需要使用php 5.6,最低要求是7。

我尝试了

composer require mopo922/laravel-treats --ignore-platform-reqs

  [InvalidArgumentException]
  Could not find package mopo922/laravel-treats at any version matching your PHP version 5.6.32.0

然后我暂时从composer文件中删除了平台要求并成功安装,但是现在我无法进行“ composer update”

composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - mopo922/laravel-treats v2.0.4 requires php >=7.0 -> your PHP version (7.2.1) overridden by "config.platform.php" version (5.6.32) does not satisfy that requirement.
    - mopo922/laravel-treats v2.0.3 requires php >=7.0 -> your PHP version (7.2.1) overridden by "config.platform.php" version (5.6.32) does not satisfy that requirement.
    - mopo922/laravel-treats v2.0.2 requires php >=7.0 -> your PHP version (7.2.1) overridden by "config.platform.php" version (5.6.32) does not satisfy that requirement.
    - mopo922/laravel-treats v2.0.1 requires php >=7.0 -> your PHP version (7.2.1) overridden by "config.platform.php" version (5.6.32) does not satisfy that requirement.
    - mopo922/laravel-treats v2.0.0 requires php >=7.0 -> your PHP version (7.2.1) overridden by "config.platform.php" version (5.6.32) does not satisfy that requirement.
    - mopo922/laravel-treats v2.0.4 requires php >=7.0 -> your PHP version (7.2.1) overridden by "config.platform.php" version (5.6.32) does not satisfy that requirement.
    - Installation request for mopo922/laravel-treats ^2.0 -> satisfiable by mopo922/laravel-treats[v2.0.0, v2.0.1, v2.0.2, v2.0.3, v2.0.4].

作曲家可以通过任何方式忽略特定软件包吗?

1 个答案:

答案 0 :(得分:0)

我在这里看到三种可能性:

  1. mopo922/laravel-treats提取所需的功能,然后直接在项目中使用。如果它只是一个很小的功能,那么作曲家不收录它就不会产生很大的影响。比搞乱版本限制恕我直言更好。
  2. 使用composer update --ignore-platform-reqs
  3. 使用platform config选项,并假冒您拥有PHP 7。 参见:How to always use ignore-platform-reqs flag when running composer? 但是,这可能会导致其他问题,例如,在安装使用PHP7约束的新软件包时,尽管您实际上并不支持它。因此,请谨慎使用。 这基本上与在您的开发机具有PHP 7时删除平台要求相同。