Composer在docker中使用自己的Symfony路径(加载旧文件)

imc*_*iac 16 php symfony laravel composer-php docker

  • 我正在使用码头工具.
  • 更新后命令(php类)在composer更新后运行.
  • 运行良好,直到我做了Laravel更新5.4-> 5.5,下载了新的Symfony软件包
  • 作曲家清除缓存没有帮助
  • 作曲家自我更新没有帮助
  • 作曲家签名是平等的

[Symfony\Component\Debug\Exception\FatalThrowableError]调用未定义的方法Illuminate\Foundation\Console\ClosureCommand :: setHidden()

我正在编写文件,这个方法存在于父类中!我把这个小东西放在构造函数中发生了什么:

use Symfony\Component\Console\Command\Command as SymfonyCommand;

class Command extends SymfonyCommand
{
    public function __construct()
    {
        $r1 = new \ReflectionClass($this);
        $r2 = new \ReflectionClass(SymfonyCommand::class);
        var_dump([$r1->getFileName(), $r2->getFileName()]);
    }
// rest of class
}
Run Code Online (Sandbox Code Playgroud)

结果:作曲家自动加载自己的旧的Command.php,而不是来自项目.

array(2) {
  [0]=>
  string(91) "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClosureCommand.php"
  [1]=>
  string(67) "phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php"
}
Run Code Online (Sandbox Code Playgroud)

我想知道为什么没有从项目加载symfony类,而是从一些神奇的地方加载,以及我如何解决这个问题.


附加信息:

添加作曲家的php的Dockerfile:

# Composer
ENV PATH "/composer/vendor/bin:$PATH"
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /composer
ENV COMPOSER_VERSION 1.4.2

RUN curl -s -f -L -o /tmp/composer-setup.php https://getcomposer.org/installer
RUN curl -s -f -L -o /tmp/composer-setup.sig https://composer.github.io/installer.sig
RUN php -r " \
    \$signature_php = hash('SHA384', file_get_contents('/tmp/composer-setup.php')); \
    \$signature_sig = trim(file_get_contents('/tmp/composer-setup.sig')); \
    echo ' SIGNATURE PHP: [' . \$signature_php . \"]\\n\"; \
    echo ' SIGNATURE SIG: [' . \$signature_sig . \"]\\n\"; \
    if (\$signature_php !== \$signature_sig) { \
        unlink('/tmp/composer-setup.php'); \
        echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \
        exit(1); \
    }"
RUN php /tmp/composer-setup.php --no-ansi --install-dir=/usr/bin cd --filename=composer --version=${COMPOSER_VERSION} \
 && rm /tmp/composer-setup.php \
 && composer --ansi --version --no-interaction
Run Code Online (Sandbox Code Playgroud)

作曲家部分:

"post-update-cmd": [
   "Modules\\Core\\Composer\\ComposerScripts::postUpdate",
   "php artisan vendor:publish --tag=public --force",
   "php artisan optimize"
],
Run Code Online (Sandbox Code Playgroud)

lui*_*ano 1

也许获取composer的签名不匹配,你必须知道签名可以改变,如果你想获取最后一个使用这个url https://composer.github.io/installer.sig

使用此片段来验证签名。

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
            php -r "if (hash_file('SHA384', 'composer-setup.php') === '$(wget -q -O - https://composer.github.io/installer.sig)') { \
                echo 'Installer good'; \
            } else { \
                echo 'Installer corrupt'; die; \
            } echo PHP_EOL;"
Run Code Online (Sandbox Code Playgroud)