今天用命令行运行composer安装依赖时突然报如下错误:
<b>Notice</b>: failed to open file: phar://composer.phar/bin/composer<b>Notice</b>: failed to open file: phar://C:/Users/Administrator/AppData/Local/ComposerSetup/bin/composer.phar/bin/../src/bootstrap.php<b>Notice</b>: failed to open file: phar://C:/Users/Administrator/AppData/Local/ComposerSetup/bin/composer.phar/src/../vendor/autoload.php<b>Notice</b>: failed to open file: phar://C:/Users/Administrator/AppData/Local/ComposerSetup/bin/composer.phar/vendor/composer/autoload_real.php<b>Notice</b>: failed to open file: phar://C:/Users/Administrator/AppData/Local/ComposerSetup/bin/composer.phar/vendor/composer/ClassLoader.php<b>Notice</b>: failed to open file: phar://C:/Users/Administrator/AppData/Local/ComposerSetup/bin/composer.phar/vendor/composer/autoload_static.php<b>Notice</b>: failed to open file: phar://C:/Users/Administrator/AppData/Local/ComposerSetup/bin/composer.phar/vendor/composer/../symfony/polyfill-php80/bootstrap.php<b>Notice</b>: failed to open file: phar://C:/Users/Administrator/AppData/Local/ComposerSetup/bin/composer.phar/vendor/composer/../symfony/deprecation-contracts/function.php<b>Notice</b>: failed to open file: phar://C:/Users/Administrator/AppData/Local/ComposerSetup/bin/composer.phar/vendor/composer/../symfony/polyfill-mbstring/bootstrap.php<b>Notice</b>: failed to open file:
。。。。。。。
习惯性的谷歌了一通,没找到任何相关的问题结果,可能遇到这个问题的人太少了吧~
乍一看,似乎是权限问题导致的未能打开composer.phar相关的文件,但是经过反复比对,发现即便是查看下composer版本,也会出现如上提示,按照网上的一些教程安装完最好重启下电脑,但是重启多次,问题依旧。。。
经过几个钟的折腾,考虑到电脑有多个PHP版本,决定尝试换个PHP版本试试,更换PHP版本后,composer一切正常,说明并非系统文件夹之类的权限问题导致,于是想到会不会是某个PHP拓展组件导致的错误,又仔细排查了下PHP拓展组件,最终发现是一个叫XLoad的PHP加密组件,导致了如上错误,进而导致composer崩溃无法正常工作。。。
实测另外一个加密组件sg13没有这个问题,说明这个xloader权限干预或者相关逻辑有处理不当的地方
大家在用composer若像我一样,遇到一些莫名其妙的问题,网上又无相关解决方案时,不妨切换下版本或者从拓展组件方面找找问题,避免多走弯路,节约时间,也希望本文能帮到遇到相同问题的朋友~
如果觉得《php composer failed to open file: phar://composer.phar/bin........问题解决》对你有帮助,请点赞、收藏,并留下你的观点哦!