composer出错的问题

composer出错的问题

composer

1.

[InvalidArgumentException]
 Could not find package laravel/laravel with stability stable.
原因 : 可能镜像出问题了,当前镜像没有这个包
解决 : 切换 composer 镜像地址;
①国外 :  composer config -g repo.packagist composer https://packagist.org
②国内 : composer config -g repo.packagist composer https://packagist.phpcomposer.com
③阿里 : composer config -g repo.packagist composer https://mirrors.aliyun.com/composer

2.

[ErrorException]
putenv() has been disabled for security reasons
原因:putenv 函数被禁用了
解决:打开php.ini 将disable_functions里的putenv删了

3.

Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
Downloading (100%)
 [ErrorException]
 zlib_decode(): data error
解决:编辑php.ini,修改zlib扩展相关配置:
 zlib.output_compression = On
 zlib.output_compression_level = 5

4.

执行composer update 等会出现
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode
解决:安装或启用fileinfo扩展


5.

  [Composer\Downloader\TransportException]
  curl error 92 while downloading https://repo.packagist.org/p2/illuminate/contracts.json: HTTP/2 stream 185 was not
  closed cleanly before end of the underlying stream


解决:换源  composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/


6.
A connection timeout was encountered. If you intend to run Composer without connecting to the internet, run the command again prefixed wi
th COMPOSER_DISABLE_NETWORK=1 to make Composer run in offline mode.
The following exception probably indicates you are offline or have misconfigured DNS resolver(s)

                                                                                                                                   
  [Composer\Downloader\TransportException]                                                                                         
  curl error 28 while downloading https://mirrors.aliyun.com/composer/packages.json: Resolving timed out after 10001 milliseconds  
                                                                                                                                   
解决:网络有问题,检查一下网络,比如 curl xxx 看能不能访问

7.
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7
.3.4. in xxxxx\vendor\composer\platform_check.php on line 24


原因: 以前用的是7.3版本,后来换成7.4版本了,php版本不一致导致的。
解决: 
①换回原来的版本;
②要么项目下composer.json 中 config 配置 添加 "platform-check": false,再执行composer dump





留下回复