错误代码 1 缓存:在作曲家需要时清除

Bar*_*art 5 symfony elasticsearch ongr

无法按照 github 示例安装/要求 ongr/elasticsearch-bundle "~5.0"。

我正在运行最新 symfony 的全新安装。

我正在运行以下命令: composer require ongr/elasticsearch-bundle "~5.0"

根据https://github.com/ongr-io/ElasticsearchBundle

composer require ongr/elasticsearch-bundle "~5.0"

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.2.*"
Package operations: 7 installs, 0 updates, 0 removals
  - Installing react/promise (v2.7.1): Loading from cache
  - Installing guzzlehttp/streams (3.0.0): Loading from cache
  - Installing guzzlehttp/ringphp (1.1.1): Loading from cache
  - Installing elasticsearch/elasticsearch (v5.5.0): Loading from cache
  - Installing ongr/elasticsearch-dsl (v5.0.6): Loading from cache
  - Installing symfony/templating (v4.2.11): Loading from cache
  - Installing ongr/elasticsearch-bundle (v5.2.4): Loading from cache
Writing lock file
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 1 recipe (c91982d16a3859d0a43fd4ff85aa437a)
  - Configuring ongr/elasticsearch-bundle (>=v5.2.4): From auto-generated recipe
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!  
!!  In ArrayNode.php line 228:
!!                                                                                
!!    The child node "managers" at path "ongr_elasticsearch" must be configured.  
!!                                                                                
!!  
!!  
Script @auto-scripts was called via post-update-cmd

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

Run Code Online (Sandbox Code Playgroud)

我能做些什么来解决这个问题?

该教程提到了一个 config.yml(我没有),如果在安装过程中它不存在,我认为会创建它

Bar*_*ada 5

问题是有一个脚本会在安装新的依赖项后立即清除 Symfony 缓存,然后您才有机会向配置文件添加正确的配置。

假设您的文件中有一个composer.json如下所示的部分:

"scripts": {
    "auto-scripts": {
        "cache:clear": "symfony-cmd",
        "assets:install %PUBLIC_DIR%": "symfony-cmd"
    },
Run Code Online (Sandbox Code Playgroud)

你应该删除这"cache:clear": "symfony-cmd"条线。如果它看起来不完全像这样,只需删除所有包含cache:clear. 成功安装和配置后,您可能希望恢复这一行/这些行ongr/elasticsearch-bundle,这样您就不必在安装与 Symfony Flex 更好兼容的捆绑包后记住手动清除缓存,或者不会成为受害者它过于热心地试图提供帮助。

或者,这可能是一个更好的解决方案 - 完全摆脱symfony/flex。当某些第三方向配方添加命令而不检查是否满足所有要求时,它有一个令人讨厌的习惯,会弄乱您的配置文件。我知道,我去过那里。

  • 与其完全删除“cache:clear”命令,不如考虑使用“composer require --no-scripts ...”来确保其他更新命令将清除缓存,以防止由于缓存过时而出现奇怪的行为。 (13认同)