沃梦达 / 编程问答 / php问题 / 正文

在作曲家中覆盖 PHP 基本依赖项

Override PHP base dependency in composer(在作曲家中覆盖 PHP 基本依赖项)

本文介绍了在作曲家中覆盖 PHP 基本依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在只有 PHP 5.5.6 的主机上安装 Laravel 5.1.虽然我要求客户升级,但这可能是不可能/不可行的.

I try to install Laravel 5.1 on a host which only has PHP 5.5.6. While I asked the customer to upgrade, this might be not possible/feasible.

所以我得到:

- This package requires php >=5.5.9 but your PHP version (5.5.6)
   does not satisfy that requirement.

关于 composer.phar 安装.

有没有办法让作曲家安装忽略这种依赖关系?

Is there a way to do a composer install which ignores this dependency?

我认为它应该是安全的,因为只有从 5.5.6 到 5.5.9 的错误修复.

I think it should be safe, as there are only bug-fixes from 5.5.6 to 5.5.9.

推荐答案

错误消息表明来自主 composer.json 的要求.版本要求可以随意调整:

The error message indicates a requirement from the main composer.json. The version requirement can be just adapted:

"require": {
    "php": ">=5.5",

像这样更改版本后,我得到:

After changing the version like this I get:

  Problem 1
    - Installation request for classpreloader/classpreloader 2.0.0 -> satisfiable by classpreloader/classpreloader[2.0.0].
    - classpreloader/classpreloader 2.0.0 requires php >=5.5.9 -> your PHP version (5.5.6) or "config.platform.php" value does not satisfy that requirement.
  Problem 2
    - Installation request for laravel/framework v5.1.17 -> satisfiable by laravel/framework[v5.1.17].
    - laravel/framework v5.1.17 requires php >=5.5.9 -> your PHP version (5.5.6) or "config.platform.php" value does not satisfy that requirement.
  Problem 3
    - Installation request for laravelcollective/html v5.1.6 -> satisfiable by laravelcollective/html[v5.1.6].
    - laravelcollective/html v5.1.6 requires php >=5.5.9 -> your PHP version (5.5.6) or "config.platform.php" value does not satisfy that requirement.
  Problem 4
    - laravel/framework v5.1.17 requires php >=5.5.9 -> your PHP version (5.5.6) or "config.platform.php" value does not satisfy that requirement.
    - jenssegers/agent v2.1.7 requires illuminate/support ~4.0|~5.0 -> satisfiable by laravel/framework[v5.1.17].
    - Installation request for jenssegers/agent v2.1.7 -> satisfiable by jenssegers/agent[v2.1.7].

composer.json中使用以下代码段,可以模拟一个php版本

Using the following snippet in composer.json, a php version can be simulated

[...]
"config": {
    "preferred-install": "dist",
    "platform": {
        "php": "5.5.9"
    }
}

文档:https://getcomposer.org/doc/06-config.md#平台

平台

允许您伪造平台包(PHP 和扩展),以便您可以模拟生产环境或在配置中定义您的目标平台.示例:{php":5.4",ext-something":4.0"}.

Lets you fake platform packages (PHP and extensions) so that you can emulate a production env or define your target platform in the config. Example: {"php": "5.4", "ext-something": "4.0"}.

不要忘记在此之后运行 composer.phar 更新

Don't forget to run a composer.phar update after this

这篇关于在作曲家中覆盖 PHP 基本依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在作曲家中覆盖 PHP 基本依赖项

基础教程推荐