Why is PHP Composer so slow?

前端 未结 13 2004
攒了一身酷
攒了一身酷 2021-01-29 19:03

Why is PHP Composer so slow when all I do is init a project with zero dependencies? Here are the commands I run:

composer init

13条回答
  •  余生分开走
    2021-01-29 19:29

    I was running into this issue, and it was throwing me for a curve since I don't have Xdebug installed anywhere on my machine. It turns out that it was IPv6 addressing mode failures. So to test I ran

    curl --ipv4 'https://packagist.org/packages.json'
    curl --ipv6 'https://packagist.org/packages.json'
    

    IPv4 went through, but IPv6 failed. In the end, you should look to find out why you're networking stack doesn't support it, but in my case, I decided to just give preference to IPv4 traffic until I can resolve that. On CentOS I created/modified the file /etc/gai.conf and put in the following:

    label       ::1/128        0
    label       ::/0           1
    label       2002::/16      2
    label       ::/96          3
    label       ::ffff:0:0/96  4
    precedence  ::1/128        50
    precedence  ::/0           40
    precedence  2002::/16      30
    precedence  ::/96          20
    precedence  ::ffff:0:0/96  100
    

    On Ubuntu you can also edit that file and uncomment the line

    precedence ::ffff:0:0/96  100
    

    Source on Rackspace Community Hub

提交回复
热议问题