最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】Mac中composer install安装php的模块卡死在Updating dependencies including require-dev

Mac crifan 457浏览 0评论

折腾:

【未解决】Mac中安装和使用composer安装php的库php-html-parser

期间,去安装php的库:

composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)

然后就没输出,没反应了。

composer install Updating dependencies

json – Composer hanging while updating dependencies – Stack Overflow

去暂时把XDebug停止掉试试

/Applications/MAMP/bin/php/php7.2.1/conf/php.ini

确保关闭了xdebug:phpinfo中找不到xdebug了

结果问题依旧:

php – Slow updating of composer dependencies, despite –prefer-dist flag – Stack Overflow

# php -m | grep xdebug

空的,没有。

试试:

composer install --prefer-dist -vvv --profile

log

➜  useHtmlLibParseEvernoteHtml composer install --prefer-dist -vvv --profile
Reading ./composer.json
Loading config file ./composer.json
Checked CA file /private/etc/ssl/cert.pem: valid
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): git branch --no-color --no-abbrev -v
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): git describe --exact-match --tags
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): git log --pretty="%H" -n1 HEAD
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): hg branch
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): fossil branch list
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): fossil tag list
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /Users/crifan/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Running 1.8.6 (2019-06-11 15:03:05) with PHP 7.1.23 on Darwin / 18.6.0
[6.1MiB/0.00s] Loading composer repositories with package information
[6.4MiB/0.01s] Downloading https://repo.packagist.org/packages.json
[6.4MiB/0.82s] Writing /Users/crifan/.composer/cache/repo/https---repo.packagist.org/packages.json into cache
[6.4MiB/0.82s] Updating dependencies (including require-dev)
[6.7MiB/0.82s] Reading /Users/crifan/.composer/cache/repo/https---repo.packagist.org/p-provider-2013.json from cache
[10.4MiB/0.84s] Reading /Users/crifan/.composer/cache/repo/https---repo.packagist.org/p-provider-2014.json from cache
[18.0MiB/0.89s] Downloading http://repo.packagist.org/p/provider-2015%24d0a229f4d124ab3c4b76c9f50e83feef697448672077bef15154a4885958c40f.json
...

稍等一会,是有进展的:

[10.4MiB/0.84s] Reading /Users/crifan/.composer/cache/repo/https---repo.packagist.org/p-provider-2014.json from cache
[18.0MiB/0.89s] Downloading http://repo.packagist.org/p/provider-2015%24d0a229f4d124ab3c4b76c9f50e83feef697448672077bef15154a4885958c40f.json
[31.7MiB/89.56s] Writing /Users/crifan/.composer/cache/repo/https---repo.packagist.org/p-provider-2015.json into cache
[30.3MiB/89.60s] Downloading http://repo.packagist.org/p/provider-2016%241ceebfcd978d1d51b3ea8ec51cdfdc5ce0462dbf308b0a7b313242829f519614.json
...

但是后续downloading依旧很慢很慢

感觉现在问题变成了:

php的composer install期间去下载repo.packagist.org的包的速度太慢

看看是否有镜像或者代理可以缓解

composer install repo.packagist.org 太慢

Packagist / Composer 中国全量镜像

composer config -g repo.packagist composer https://packagist.phpcomposer.com

然后重新试试:

composer install --prefer-dist -vvv --profile

速度就很快了:

瞬间就安装完毕了:

➜  useHtmlLibParseEvernoteHtml composer install --prefer-dist -vvv --profile                               
Reading ./composer.json
Loading config file /Users/crifan/.composer/config.json
Loading config file /Users/crifan/.composer/auth.json
Loading config file ./composer.json
Checked CA file /private/etc/ssl/cert.pem: valid
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): git branch --no-color --no-abbrev -v
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): git describe --exact-match --tags
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): git log --pretty="%H" -n1 HEAD
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): hg branch
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): fossil branch list
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): fossil tag list
Executing command (/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /Users/crifan/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Running 1.8.6 (2019-06-11 15:03:05) with PHP 7.1.23 on Darwin / 18.6.0
[6.1MiB/0.01s] Loading composer repositories with package information
[6.4MiB/0.01s] Downloading https://packagist.phpcomposer.com/packages.json
[6.4MiB/0.28s] Writing /Users/crifan/.composer/cache/repo/https---packagist.phpcomposer.com/packages.json into cache
[6.4MiB/0.28s] Updating dependencies (including require-dev)
[6.7MiB/0.29s] Downloading https://repo.packagist.org/p/paquettg/php-html-parser.json
[6.9MiB/1.36s] Writing /Users/crifan/.composer/cache/repo/https---packagist.phpcomposer.com/provider-paquettg$php-html-parser.json into cache
[6.8MiB/1.37s] Downloading https://repo.packagist.org/p/paquettg/string-encode.json
[6.9MiB/2.94s] Writing /Users/crifan/.composer/cache/repo/https---packagist.phpcomposer.com/provider-paquettg$string-encode.json into cache
[7.0MiB/2.95s] Resolving dependencies through SAT
[7.0MiB/2.95s] Looking at all rules.
[7.1MiB/2.95s] Something's changed, looking at all rules again (pass #1)[7.1MiB/2.95s] 
[7.1MiB/2.95s] Dependency resolution completed in 0.001 seconds
[7.1MiB/2.95s] Analyzed 86 packages to resolve dependencies
[7.1MiB/2.95s] Analyzed 71 rules to resolve dependencies
[7.1MiB/2.95s] Package operations: 2 installs, 0 updates, 0 removals
[7.1MiB/2.95s] Installs: paquettg/string-encode:1.0.1, paquettg/php-html-parser:2.0.2
[7.1MiB/2.95s]   - Installing paquettg/string-encode (1.0.1): [7.2MiB/2.96s] Downloading https://api.github.com/repos/paquettg/string-encoder/zipball/a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee
[7.2MiB/2.96s] Downloading (connecting...)[7.2MiB/3.70s] 
[7.2MiB/3.70s] Following redirect (2) https://codeload.github.com/paquettg/string-encoder/legacy.zip/a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee
[7.3MiB/3.70s] Downloading https://codeload.github.com/paquettg/string-encoder/legacy.zip/a8708e9fac9d5ddfc8fc2aac6004e2cd05d80fee
[7.3MiB/4.46s] Downloading (0%)[7.3MiB/4.46s]                                                                         [7.3MiB/4.46s] Downloading (70[7.3MiB/4.46s] Downloading (100%)[7.2MiB/4.46s] Writing /Users/crifan/.composer/cache/files/paquettg/string-encode/563c1301de18825c399c18b2234b9b38eaba589d.zip into cache from /Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml/vendor/paquettg/string-encode/693f81608e274a2e75848f64224def82
[7.2MiB/4.46s] 
[7.2MiB/4.46s]  Extracting archive[7.2MiB/4.46s] Executing command (CWD): unzip -qq  '/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml/vendor/paquettg/string-encode/693f81608e274a2e75848f64224def82' -d '/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml/vendor/composer/1ad592ca'
[7.3MiB/4.50s]     REASON: paquettg/php-html-parser 2.0.2 requires paquettg/string-encode ~1.0.0 -> satisfiable by paquettg/string-encode[1.0.0, 1.0.1].
[7.3MiB/4.50s] 
[7.3MiB/4.50s]   - Installing paquettg/php-html-parser (2.0.2): [7.3MiB/4.50s] Downloading https://api.github.com/repos/paquettg/php-html-parser/zipball/77e4a44b0916690b4300fe9abf98fd05bbba48f0
[7.3MiB/4.52s] Downloading (connecting...)[7.3MiB/5.58s] 
[7.3MiB/5.58s] Following redirect (2) https://codeload.github.com/paquettg/php-html-parser/legacy.zip/77e4a44b0916690b4300fe9abf98fd05bbba48f0
[7.3MiB/5.58s] Downloading https://codeload.github.com/paquettg/php-html-parser/legacy.zip/77e4a44b0916690b4300fe9abf98fd05bbba48f0
[7.3MiB/6.38s] Downloading (0%)[7.3MiB/6.38s]                                                                         [7.3MiB/6.38s] Downloading (35[7.3MiB/6.38s] Downloading (40[7.3MiB/6.49s] Downloading (75[7.3MiB/6.49s] Downloading (80[7.3MiB/6.71s] Downloading (100%)[7.3MiB/6.71s] Writing /Users/crifan/.composer/cache/files/paquettg/php-html-parser/4d2503a574c63a4e10385770b4cca3d10127cb8d.zip into cache from /Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml/vendor/paquettg/php-html-parser/b864b9658652377d978d0ca24d33c176
[7.3MiB/6.71s] 
[7.3MiB/6.71s]  Extracting archive[7.3MiB/6.71s] Executing command (CWD): unzip -qq  '/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml/vendor/paquettg/php-html-parser/b864b9658652377d978d0ca24d33c176' -d '/Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml/vendor/composer/71b40cc3'
[7.3MiB/6.76s]     REASON: Required by the root package: Install command rule (install paquettg/php-html-parser 2.0.2)
[7.3MiB/6.76s] 
[7.0MiB/8.32s] Reading /Users/crifan/dev/dev_root/crifan.com/mamp/test/useHtmlLibParseEvernoteHtml/vendor/composer/installed.json
[7.0MiB/8.32s] Writing lock file
[7.0MiB/8.32s] Generating autoload files
[7.0MiB/8.32s] Memory usage: 6.98MiB (peak: 7.35MiB), time: 8.32s

【总结】

此处php的composer install慢的原因:

1.首先排查的是XDebug

并不是表示你一定开启了XDebug,而是当前运行:

composer install

的命令行中,php是否加载啦XDebug

可以通过:

php -m | grep xdebug

确认没有XDebug

如果有加载,注释掉配置,比如此处的:

/Applications/MAMP/bin/php/php7.2.1/conf/php.ini

[xdebug]
; zend_extension="/Applications/MAMP/bin/php/php7.2.1/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so"
; xdebug.remote_autostart=1
; xdebug.remote_enable=1
; xdebug.remote_host=localhost
; xdebug.remote_port=9000
; xdebug.remote_handler=dbgp

2.如果还慢,那去加上 verbose参数:

composer install --prefer-dist -vvv --profile

这样可以看出来具体慢在哪里。

3.如果是和我一样,是慢在

Downloading http://repo.packagist.org/...

那可以通过添加镜像解决

配置全局的镜像

composer config -g repo.packagist composer https://packagist.phpcomposer.com

再去:

composer install

就很快了。此处几十秒就安装完毕了。

转载请注明:在路上 » 【已解决】Mac中composer install安装php的模块卡死在Updating dependencies including require-dev

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
75 queries in 0.144 seconds, using 18.88MB memory