Composer 提示 zlib_decode (): data error

Composer 提示 zlib_decode (): data error

下面由composer命令使用教程栏目记录一下解决这个问题的方法,遇到有几次了,印象中每次解决的方法都不一样

环境说明

  1. CentOS Linux 7PHP 5.6.36Composer 1.8.6

登录后复制

亚马逊香港服务器

原始输出

清除缓存

  1. $ composer clearcacheCache directory does not exist (cache-vcs-dir): Clearing cache (cache-repo-dir): /home/work/.cache/composer/repoClearing cache (cache-files-dir): /home/work/.cache/composer/filesClearing cache (cache-dir): /home/work/.cache/composerAll caches cleared.

登录后复制

校验

  1. $ composer diagnoseChecking composer.json: OKChecking platform settings: OKChecking git settings: OKChecking http connectivity to packagist: OKChecking https connectivity to packagist: OKChecking github.com rate limit: OKChecking disk free space: OKComposer version: 1.8.6PHP version: 5.6.36PHP binary path: /home/work/apps/php/bin/php

登录后复制

查看配置

  1. $ composer config -l[repositories.packagist.org.type] composer[repositories.packagist.org.url] https://mirrors.aliyun.com/composer/[process-timeout] 300[use-include-path] false[preferred-install] auto[notify-on-install] true[github-protocols] [https, ssh][vendor-dir] vendor (/home/work/www/wanglong/vendor)[bin-dir] {$vendor-dir}/bin (/home/work/www/wanglong/vendor/bin)[cache-dir] /home/work/.cache/composer[data-dir] /home/work/.local/share/composer[cache-files-dir] {$cache-dir}/files (/home/work/.cache/composer/files)[cache-repo-dir] {$cache-dir}/repo (/home/work/.cache/composer/repo)[cache-vcs-dir] {$cache-dir}/vcs (/home/work/.cache/composer/vcs)[cache-ttl] 15552000[cache-files-ttl] 15552000[cache-files-maxsize] 300MiB (314572800)[bin-compat] auto[discard-changes] false[autoloader-suffix] [sort-packages] false[optimize-autoloader] false[classmap-authoritative] false[apcu-autoloader] false[prepend-autoloader] true[github-domains] [github.com][bitbucket-expose-hostname] true[disable-tls] false[secure-http] true[cafile] [capath] [github-expose-hostname] true[gitlab-domains] [gitlab.com][store-auths] prompt[archive-format] tar[archive-dir] .[htaccess-protect] true[home] /home/work/.config/composer

登录后复制

安装

Composer 提示 zlib_decode (): data error

调试过程

Round One

一看到这个问题,首先看了一下 composer 版本,不是最新版本,升级一下吧

  1. $ composer self-update  [SymfonyComponentConsoleExceptionCommandNotFoundException]    Command "self-update" is not defined.

登录后复制

Composer 提示 zlib_decode (): data error

命令不存在,想了一下,我的用户好像权限不足,算了吧。。。。

Round Two

Google 一下,搜索结果第一条的解决方案是换源,本来用的是阿里云的源,换一下吧

  1. $ composer config repo.packagist composer http://packagist.phpcomposer.com

登录后复制

换个镜像之后,composer.json 长这样

  1. {    "license": "proprietary",    "require": {        "php": ">=5.6",        "guzzlehttp/guzzle": "^6.3",        "aws/aws-sdk-php": "^3.52"    },    "autoload": {        "psr-4": {            "Rpc\": "application/library/Rpc/"        }    },    "repositories": {        "packagist": {            "type": "composer",            "url": "http://packagist.phpcomposer.com"        }    }}

登录后复制

安装

Composer 提示 zlib_decode (): data error

不支持 http 只支持 https,想了想还是不改这个配置吧,不止我一个人用这台机。。。。

Round Three

我想了下,既然是国外的服务器,我干脆直接把镜像源全去了,都用默认的,说干就干

  1. composer config ---unset repos.packagistcomposer config --unset repos.packagistcomposer clearcachecomposer diagnosecomposer install -vvv

登录后复制

然后安装,直接安装成功了???我还没反应过来。由于 composer install -vvv 输出的日志太长了,不太方便截图,放一个 composer install 的输出截图

Composer 提示 zlib_decode (): data error

结论

本次问题的解决方法是去掉所有的镜像源,直接用默认的镜像源安装,应该只适用于国外的服务器。

以上就是Composer 提示 zlib_decode (): data error的详细内容,更多请关注【创想鸟】其它相关文章!

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

点点赞赏,手留余香

给TA打赏
共0人
还没有人赞赏,快来当第一个赞赏的人吧!
    编程技术

    Composer常用的命令整理

    2025-3-13 15:07:54

    编程技术

    php json_encode如何使用

    2025-3-13 15:08:04

    0 条回复 A文章作者 M管理员
    欢迎您,新朋友,感谢参与互动!
      暂无讨论,说说你的看法吧
    个人中心
    购物车
    优惠劵
    今日签到
    私信列表
    搜索