禁止“模糊类解析";作曲家转储自动加载 -o 上的警告

2022-01-21 00:00:00 deployment openshift php composer-php

我的情况如下:

我想通过 openshift 上的git push"部署一个 php-app.依赖关系通过作曲家解决.composer.lock 文件(将依赖项锁定到特定的所需版本)是存储库的一部分.

I want to deploy a php-app via "git push" on openshift. Dependencies are resolved via composer. The composer.lock file (locking the dependencies to the specific wanted version) is part of the repository.

使用 deploy 钩子脚本加载依赖项:

Dependencies are loaded using the deploy hook script using:

${PHP_DIR}/bin/php $OPENSHIFT_DATA_DIR/composer.phar update --prefer-dist --no-dev -n
${PHP_DIR}/bin/php $OPENSHIFT_DATA_DIR/composer.phar dump-autoload --optimize -n

其中一个依赖项(htmlpurifier)是子依赖项的依赖项.在第二个命令(dump-autoload --optimize)期间,一个抱怨不明确的类解析"的错误被写入 stderr(我想),导致部署失败.代码在本地使用单元/集成测试进行测试,并证明可以工作,即使使用这个错误的包.

One of the dependencies (htmlpurifier) is a dependency of a subdependency. During the second command (dump-autoload --optimize) an error complaining about a "Ambiguous class resolution"-warning is written to stderr(I suppose), causing the deploy to fail. Code is tested locally using unit/integration tests and proven to work, even with this erroneous package.

远程:警告:不明确的类解析,HTML5"在两个/var/lib"中都找到/openshift/abc/app-root/runtime/repo/vendor/ezyang/htmlpurifier/maintenance/PH5P.php"和/var/lib/openshift/abc/app-根/运行时/repo/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php",将使用第一个.

remote: Warning: Ambiguous class resolution, "HTML5" was found in both "/var/lib /openshift/abc/app-root/runtime/repo/vendor/ezyang/htmlpuri fier/maintenance/PH5P.php" and "/var/lib/openshift/abc/app- root/runtime/repo/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php ", the first will be used.

他们是否可以忽略此特定警告(例如未记录的选项),而不忽略命令生成的所有其他警告和/或消息?或者是否可以从自动加载优化中排除特定的子依赖项以避免警告并让部署成功而​​不忽略所有可能的错误?

Is their a way to ignore this specific warning (e.g. an undocumented option), without ignoring all other warnings and/or messages generated by the command? Or is it possible to exclude a specific subdependency from autoload optimization to avoid the warning and let deploy succeed without ignoring all possible errors?

推荐答案

在对作曲家用户列表进行讨论后,此问题已修复

After a discussion on the composer-user list this has been fixed in

https://github.com/composer/composer/commit/05d9912f97a2decf6a5c08dfa569dcf23d79b16d

如果其他人遇到此问题,请使用

If anyone else runs into this, update composer to the latest version using

composer selfupdate

相关文章