无法在 php 7.2.9 中使用 composer 安装 mpdf

Posted

技术标签:

【中文标题】无法在 php 7.2.9 中使用 composer 安装 mpdf【英文标题】:Can't install mpdf using composer in php 7.2.9 【发布时间】:2018-09-27 12:00:50 【问题描述】:

我正在尝试使用 composer 命令安装 mpdf: 作曲家需要 mpdf/mpdf

但我收到此错误:

Problem 1
    - Conclusion: don't install mpdf/mpdf v7.1.5
    - Conclusion: don't install mpdf/mpdf v7.1.4
    - Conclusion: don't install mpdf/mpdf v7.1.3
    - Conclusion: don't install mpdf/mpdf v7.1.2
    - Conclusion: don't install mpdf/mpdf v7.1.1
    - Conclusion: remove setasign/fpdi v2.1.0
    - Installation request for mpdf/mpdf ^7.1 -> satisfiable by mpdf/mpdf[v7.1.0, v7.1.1, v7.1.2, v7.1.3, v7.1.4, v7.1.5].
    - Conclusion: don't install setasign/fpdi v2.1.0
    - mpdf/mpdf v7.1.0 requires setasign/fpdi 1.6.* -> satisfiable by setasign/fpdi[1.6.0, 1.6.1, 1.6.2].
    - Can only install one of: setasign/fpdi[1.6.0, v2.1.0].
    - Can only install one of: setasign/fpdi[1.6.1, v2.1.0].
    - Can only install one of: setasign/fpdi[1.6.2, v2.1.0].
    - Installation request for setasign/fpdi (locked at v2.1.0) -> satisfiable by setasign/fpdi[v2.1.0].

安装失败,正在将 ./composer.json 还原为其原始内容。

这是我的 composer.json


  "lynx39/lara-pdf-merger": "1.0.*",
  "name": "laravel/laravel",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "type": "project",
  "require": 
    "php": "^7.1.3",
    "codedge/laravel-fpdf": "^1.2",
    "crabbly/fpdf-laravel": "^1.0",
    "cyber-duck/laravel-excel": "^1.2",
    "dompdf/dompdf": "^0.8.2",
    "fideloper/proxy": "^4.0",
    "jurosh/pdf-merge": "^2.0",
    "laravel/framework": "5.6.*",
    "laravel/passport": "^7.0",
    "laravel/tinker": "^1.0",
    "maatwebsite/excel": "^3.0",
    "mpdf/mpdf": "^7.1",
    "paragonie/random_compat": "2.*",
    "phpoffice/phpspreadsheet": "^1.4",
    "phpoffice/phpword": "^0.15.0",
    "rguedes/pdfmerger": "^1.0",
    "setasign/fpdi-fpdf": "^2.0",
    "tecnickcom/tc-lib-pdf": "dev-master"
  ,
  "require-dev": 
    "filp/whoops": "^2.0",
    "fzaninotto/faker": "^1.4",
    "mockery/mockery": "^1.0",
    "nunomaduro/collision": "^2.0",
    "phpunit/phpunit": "^7.0"
  ,
  "autoload": 
    "classmap": [
      "database/seeds",
      "database/factories"
    ],
    "psr-4": 
      "App\\": "app/"              ,     "autoload-dev":          "psr-4":              "Tests\\": "tests/"              ,     "extra":          "laravel":              "dont-discover": [             ]              ,     "scripts":          "post-root-package-install": [             "@php-r\"file_exists('.env') || copy('.env.example', '.env');\""
],
  "post-create-project-cmd": [
    "@php artisan key:generate"
  ],
  "post-autoload-dump": [
    "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
    "@php artisan package:discover"
  ]
,
  "config": 
    "preferred-install": "dist",
    "sort-packages": true,
    "optimize-autoloader": true
  ,
  "minimum-stability": "dev",
  "prefer-stable": true

有什么办法吗??

【问题讨论】:

需要更新您的作曲家。 更新 composer 版本或 composer.json 文件? 作曲家更新 你使用的 PHP 版本 更新您的作曲家或发布 composer.json 的内容 【参考方案1】:

mPDF 7.xsetasign/fpdi 版本 2.x 不兼容 - 使用版本 1.6

对于setasign/fpdi 2.x 升级到mPDF 8.x

【讨论】:

以上是关于无法在 php 7.2.9 中使用 composer 安装 mpdf的主要内容,如果未能解决你的问题,请参考以下文章

PHP 设置错误:Composer 无法使用您当前的设置

PHP 可执行文件无法处理 composer.phar

无法使用 PHP 5.6.3 与 Composer 建立 SSL 连接

带有 Composer 的 GCP 无法运行 PHP,无法识别“应用程序”

无法使用 composer 在 laravel 中安装 PHP-FFMpeg/PHP-FFMpeg 库

PHP Composer更新“无法分配内存”错误(使用Laravel 4)