Composer在Windows(WSL)上不起作用

时间:2018-07-16 14:49:16

标签: php docker composer-php windows-subsystem-for-linux

当此容器在Windows(Ubuntu bash / WSL)上运行时,安装Composer并尝试运行它似乎不适用于php-fpm容器。

但是,它在其他地方都可以顺利运行。

username@docker-php:/var/www/project$ php composer.phar update                                                      


  [ErrorException]                                                                                                              
  include(phar:///var/www/project/composer.phar/vendor/composer/../../src/Composer/Command/RunScriptCommand.php   
  ): failed to open stream: phar error: Cannot open phar archive "/var/www/project/composer.phar" for reading     

另外,再次运行命令会导致另一个错误:

username@docker-php:/var/www/project$ php composer.phar update                                                      

Warning: include(phar:///var/www/project/composer.phar/vendor/composer/../../src/Composer/Util/Silencer.php): fail
ed to open stream: phar error: Cannot open phar archive "/var/www/project/composer.phar" for reading in phar:///va
r/www/project/composer.phar/vendor/composer/ClassLoader.php on line 444                                           

Warning: include(): Failed opening 'phar:///var/www/project/composer.phar/vendor/composer/../../src/Composer/Util/
Silencer.php' for inclusion (include_path='.:/usr/local/lib/php') in phar:///var/www/project/composer.phar/vendor/
composer/ClassLoader.php on line 444                                                                                            

Fatal error: Uncaught Error: Class 'Composer\Util\Silencer' not found in phar:///var/www/project/composer.phar/src
/Composer/Console/Application.php:71                                                                                            
Stack trace:                                                                                                                    
#0 phar:///var/www/project/composer.phar/bin/composer(58): Composer\Console\Application->__construct()            
#1 /var/www/project/composer.phar(24): require('phar:///var/www...')                                              
#2 {main}                                                                                                                       
  thrown in phar:///var/www/project/composer.phar/src/Composer/Console/Application.php on line 71  

有什么主意要怎么做吗?

1 个答案:

答案 0 :(得分:0)

修复了以其他方式安装Composer的问题!

RUN curl -sS https://getcomposer.org/installer | php \
            && mv composer.phar /usr/local/bin/ \
            && ln -s /usr/local/bin/composer.phar /usr/local/bin/composer