使用 Composer 和 Symfony 进行故障排除

Troubleshooting with Composer and Symfony

我在使用 composer require dompdf/dompdf 时遇到了一些麻烦。 我的结果是:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - don't install symfony/var-dumper v4.0.12|don't install symfony/symfony v3.3.17
    - don't install symfony/var-dumper v4.0.12|remove symfony/symfony v3.3.17
    - don't install symfony/var-dumper v4.0.12|don't install symfony/symfony v3.3.17
    - Installation request for symfony/var-dumper 4.0.12 -> satisfiable by symfony/var-dumper[v4.0.12].
    - Installation request for symfony/symfony 3.3.17 -> satisfiable by symfony/symfony[v3.3.17].


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

我已经删除了我的供应商目录,创建了 composer update 但我遇到了同样的错误。

这是我的 composer.json

{
  "name": "tang/project",
  "license": "proprietary",
  "type": "project",
  "autoload": {
    "psr-4": {
      "AppBundle\": "src/AppBundle"
    },
    "classmap": [
      "app/AppKernel.php",
      "app/AppCache.php"
    ]
  },
  "autoload-dev": {
    "psr-4": {
      "Tests\": "tests/"
    },
    "files": [
      "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
    ]
  },
  "require": {
    "php": ">=5.5.9",
    "cocur/slugify": "^3.1",
    "composer/ca-bundle": "^1.1",
    "doctrine/annotations": "^1.6",
    "doctrine/cache": "^1.7",
    "doctrine/doctrine-bundle": "^1.9",
    "doctrine/doctrine-cache-bundle": "^1.3",
    "doctrine/doctrine-migrations-bundle": "^1.0",
    "doctrine/inflector": "^1.3",
    "doctrine/migrations": "^1.8",
    "doctrine/orm": "^2.5",
    "doctrine/reflection": "^1.0",
    "dompdf/dompdf": "^0.8.3",
    "friendsofsymfony/user-bundle": "^2.1",
    "gedmo/doctrine-extensions": "^2.4",
    "guzzlehttp/guzzle": "^6.3",
    "hwi/oauth-bundle": "^0.5.3",
    "incenteev/composer-parameter-handler": "^2.1",
    "knplabs/gaufrette": "^0.6.0",
    "knplabs/knp-components": "^1.3",
    "knplabs/knp-gaufrette-bundle": "^0.5.3",
    "knplabs/knp-menu": "^2.3",
    "knplabs/knp-menu-bundle": "^2.2",
    "knplabs/knp-paginator-bundle": "^2.8",
    "kriswallsmith/buzz": "0.16.1",
    "league/oauth2-client": "^2.3",
    "ocramius/package-versions": "^1.3",
    "paragonie/random_compat": "2.0.17",
    "psr/simple-cache": "^1.0",
    "sensio/distribution-bundle": "^5.0",
    "sensio/framework-extra-bundle": "3.0.29",
    "sensio/generator-bundle": "^3.1",
    "sensiolabs/security-checker": "^4.1",
    "sonata-project/admin-bundle": "3.36.0",
    "sonata-project/block-bundle": "^3.12",
    "sonata-project/cache": "^2.0",
    "sonata-project/core-bundle": "^3.11",
    "sonata-project/datagrid-bundle": "^2.3",
    "sonata-project/doctrine-orm-admin-bundle": "3.6.1",
    "sonata-project/exporter": "^1.9",
    "stof/doctrine-extensions-bundle": "^1.3",
    "swiftmailer/swiftmailer": "5.4.9",
    "symfony/assetic-bundle": "^2.8",
    "symfony/monolog-bundle": "3.2.0",
    "symfony/phpunit-bridge": "^4.1",
    "symfony/polyfill-apcu": "^1.8",
    "symfony/polyfill-intl-icu": "^1.8",
    "symfony/polyfill-mbstring": "^1.8",
    "symfony/polyfill-php56": "^1.8",
    "symfony/polyfill-php70": "^1.8",
    "symfony/polyfill-php72": "^1.8",
    "symfony/polyfill-util": "^1.8",
    "symfony/security-acl": "3.0.1",
    "symfony/swiftmailer-bundle": "2.6.7",
    "symfony/symfony": "3.3.17",
    "symfony/var-dumper": "4.0.12",
    "twig/twig": "^2.5",
    "vich/uploader-bundle": "1.7.1",
    "zendframework/zend-eventmanager": "^3.2"
  },
  "require-dev": {
  },
  "scripts": {
    "symfony-scripts": [
      "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
      "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
      "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
      "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
      "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
      "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
    ],
    "post-install-cmd": [
      "@symfony-scripts"
    ],
    "post-update-cmd": [
      "@symfony-scripts"
    ]
  },
  "config": {
    "sort-packages": true
  },
  "extra": {
    "symfony-app-dir": "app",
    "symfony-bin-dir": "bin",
    "symfony-var-dir": "var",
    "symfony-web-dir": "web",
    "symfony-tests-dir": "tests",
    "symfony-assets-install": "relative",
    "incenteev-parameters": {
      "file": "app/config/parameters.yml"
    },
    "branch-alias": null
  }
}

有人可以帮我吗? 谢谢

尝试删除

"symfony/var-dumper": "4.0.12" 

并使用

"symfony/var-dumper": "3.3.*" 

在你的 composer.json 中,因为 var-dumper v4.0.12 需要 symfony4 而你正在使用 symfony3