首頁 > 開發工具 > composer > Composer 提示 zlib_decode(): 資料錯誤

Composer 提示 zlib_decode(): 資料錯誤

藏色散人
發布: 2019-10-15 14:05:53
轉載
3574 人瀏覽過

Composer 提示 zlib_decode(): 資料錯誤

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

环境说明

1

2

3

CentOS Linux 7

PHP 5.6.36

Composer 1.8.6

登入後複製

亚马逊香港服务器

原始输出

清除缓存

1

2

3

4

5

6

$ composer clearcache

Cache directory does not exist (cache-vcs-dir):

Clearing cache (cache-repo-dir): /home/work/.cache/composer/repo

Clearing cache (cache-files-dir): /home/work/.cache/composer/files

Clearing cache (cache-dir): /home/work/.cache/composer

All caches cleared.

登入後複製

校验

1

2

3

4

5

6

7

8

9

10

11

$ composer diagnose

Checking composer.json: OK

Checking platform settings: OK

Checking git settings: OK

Checking http connectivity to packagist: OK

Checking https connectivity to packagist: OK

Checking github.com rate limit: OK

Checking disk free space: OK

Composer version: 1.8.6

PHP version: 5.6.36

PHP binary path: /home/work/apps/php/bin/php

登入後複製

查看配置

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

$ 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(): 資料錯誤

调试过程

Round One

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

1

2

3

$ composer self-update

  [Symfony\Component\Console\Exception\CommandNotFoundException] 

  Command "self-update" is not defined.

登入後複製

Composer 提示 zlib_decode(): 資料錯誤

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

Round Two

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

1

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

登入後複製

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

{

    "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(): 資料錯誤

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

Round Three

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

1

2

3

4

5

composer config -g --unset repos.packagist

composer config --unset repos.packagist

composer clearcache

composer diagnose

composer install -vvv

登入後複製

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

Composer 提示 zlib_decode(): 資料錯誤

结论

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

以上是Composer 提示 zlib_decode(): 資料錯誤的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
composer安裝TP51失敗
來自於 1970-01-01 08:00:00
0
0
0
composer全局
來自於 1970-01-01 08:00:00
0
0
0
php study 安裝 composer 用不了
來自於 1970-01-01 08:00:00
0
0
0
php - 使用composer出錯
來自於 1970-01-01 08:00:00
0
0
0
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板