【问题标题】:Symfony 2 an error occurred when executing the "composer install" commandSymfony 2 执行“composer install”命令时出错
【发布时间】:2023-03-13 15:54:01
【问题描述】:

Symfony 2.4

当我运行composer install 时,我看到这样的错误:

Generating autoload files

Fatal error: Class 'Doctrine\ORM\Tools\Console\Command\ClearCache\CollectionRegionCommand' not found in /Users/vpx/www/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Command/Proxy/CollectionRegionDoctrineCommand.php on line 29
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception



  [RuntimeException]                                                         
  An error occurred when executing the "'cache:clear --no-warmup'" command.  

在 composer.json 从"doctrine/orm": "~2.2,>=2.2.3" 更改为"doctrine/orm": "~2.2.3" 之后就可以了。这是为什么呢?

【问题讨论】:

    标签: php symfony doctrine-orm composer-php


    【解决方案1】:

    您确实以您可能没有看到的方式更改了版本。

    "doctrine/orm": "~2.2,>=2.2.3"
    

    这允许从 2.2.3 开始的版本(最后一个限制),不包括 3.0,而是 2.9999.9999。

    "doctrine/orm": "~2.2.3"
    

    这允许从 2.2.3 开始的版本,最高不包括 2.3.0,而是 2.2.9999。

    因此,您的更改实际上禁止了 2.3.* 及更高版本,这可能是失败的原因,因为该特定库已经发布了 2.4.2 版,现在不允许使用。

    您可能应该更新该版本要求,因为执行某些更新的安装后命令似乎不适用于该库的 2.2.x 版本。我建议至少使用 ~2.3,因为这也将排除 2.2.2 及以下版本,如之前所做的那样。

    【讨论】:

      【解决方案2】:

      尝试运行composer update 而不是composer install。

      如果这不起作用,请尝试在composer.json 中将"doctrine/orm": "~2.3.3" 替换为"doctrine/orm": "dev-master"。

      【讨论】:

      • 如果可以避免的话,永远不要使用分支。这会让事情变得更糟。
      猜你喜欢
      • 2019-07-12
      • 2018-04-30
      • 1970-01-01
      • 1970-01-01
      • 2021-04-06
      • 2019-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-03
      相关资源
      最近更新 更多