PHP作曲家安装问题

时间:2017-10-01 17:56:21

标签: php symfony composer-php

我对php composer有一个很大的问题,我运行这个命令

php composer.phar install

但是它显示了这个错误

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:
  PHP Warning:  require_once(/var/www/lcp-api/app/bootstrap.php.cache): failed to open stream: No such file or directory in /var/www/lcp-api/app/console on line 10
  PHP Fatal error:  require_once(): Failed opening required '/var/www/lcp-api/app/bootstrap.php.cache' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/
  lcp-api/app/console on line 10
  .

我检查文件composer.json,似乎一切正常

"post-install-cmd": [
      "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::removeSymfonyStandardFiles",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ],
    "post-update-cmd": [
      "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::removeSymfonyStandardFiles",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ]
  },

你知道我为什么会收到这个错误吗?

亲切

1 个答案:

答案 0 :(得分:1)

您的bootstrap.php.cache文件似乎丢失了。 Symfony有时会发生这种情况。

如果您运行composer update而不是install,则应重新生成文件。如果这不起作用,您可以通过从项目的根目录运行此命令来手动生成它:

php vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php

如果这也不起作用,您可以尝试通过运行这样的编辑器来强制您的环境进入生产模式:

SYMFONY_ENV=prod composer install

请记住,如果在开发环境中执行此操作,则将禁用调试模式。这应该生成一个bootstrap.php.cache文件,这样你就可以再次以dev模式重新运行composer。