【问题标题】:How to download the latest dev version of PHPword using composer?如何使用 Composer 下载 PHPword 的最新开发版本?
【发布时间】:2018-05-06 16:14:29
【问题描述】:

几个月前,我在我的 cakephp 项目中使用 composer 安装了 PHPword。最近我们面临一些限制,为了我们的幸福,github 上的版本有很多满足我们需求的更新。

我们已尝试composer update,但最新版本仍然是 2016 版 之后我们尝试了这个:

composer require phpoffice/phpword:dev

结果是:

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
    - The requested package phpoffice/phpword dev exists as phpoffice/phpword[0.
10.0, 0.10.1, 0.11.0, 0.11.1, 0.12.0, 0.7.0, 0.8.0, 0.8.1, 0.9.0, 0.9.1, dev-dev
elop, dev-master, v0.12.1, v0.13.0] but these are rejected by your constraint.


Installation failed, reverting ./composer.json to its original content.

编辑:我们需要 composer.json:

"require": {
        "php": ">=5.6",
        "cakephp/cakephp": "3.4.*",
        "mobiledetect/mobiledetectlib": "2.*",
        "cakephp/migrations": "~1.0",
        "cakephp/plugin-installer": "*",
        "mpdf/mpdf": "^6.1",
        "tecnickcom/tcpdf": "^6.2",
        "phpoffice/phpexcel": "^1.8",
        "box/spout": "^2.7",
        "cakecoded/ckeditor": "^1.0",
        "phpoffice/phpword": "dev-master",
        "dompdf/dompdf": "^0.8.0",
        "fgrosse/phpasn1": "^2.0",
        "sop/asn1": "^2.0",
        "sop/x509": "^0.5.0"
    },

那么,有没有办法获得即使在开发中的最新版本?

提前致谢!

【问题讨论】:

  • 如果没有 composer.json 的 require 部分,就不可能知道冲突的原因。

标签: php composer-php phpword


【解决方案1】:

您现在可以使用 dev-master 版本,或者等待几天获得正式的 0.14 版本。

【讨论】:

    【解决方案2】:

    为您的 composer.json 添加依赖项

    {
        "require": {
           "phpoffice/phpword": "v0.13.*"
        }
    }
    

    然后尝试运行

    composer update
    

    【讨论】:

      【解决方案3】:

      尝试运行

      $ composer require phpoffice/phpword:dev-master
      

      如果这不起作用,请调整您的 composer.json 以包含

      {
          "minimum-stability": "dev",
          "prefer-stable: true
      }
      

      参考,见

      注意

      正如所指出的,如果您在使用 composer 安装软件包时遇到问题,最好分享您的 composer.json,以便我们提供更好的帮助。

      【讨论】:

      • 您好,我的项目文件夹中有一个 composer.json,在 vendor\phpoffice\phpword 中有另一个我需要更改哪些?
      • 你项目中的那个——你会在vendor/中找到的是你需要的那些包。