问题说明:
执行composer install遇到错误:Your requirements could not be resolved to an installable set of packages. 这是因为不匹配composer.json要求的版本。
$ composer install
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel-notification-channels/webpush 3.0.0 requires minishlink/web-push ^2.0 -> satisfiable by minishlink/web-push[v2.0.0, v2.0.1].
- laravel-notification-channels/webpush 3.0.1 requires minishlink/web-push ^2.0 -> satisfiable by minishlink/web-push[v2.0.0, v2.0.1].
- minishlink/web-push v2.0.0 requires mdanter/ecc ^0.5.0 -> satisfiable by mdanter/ecc[v0.5.0, v0.5.1, v0.5.2].
- minishlink/web-push v2.0.1 requires mdanter/ecc ^0.5.0 -> satisfiable by mdanter/ecc[v0.5.0, v0.5.1, v0.5.2].
- mdanter/ecc v0.5.2 requires ext-gmp * -> the requested PHP extension gmp is missing from your system.
- mdanter/ecc v0.5.1 requires ext-gmp * -> the requested PHP extension gmp is missing from your system.
- mdanter/ecc v0.5.0 requires ext-gmp * -> the requested PHP extension gmp is missing from your system.
- Installation request for laravel-notification-channels/webpush ^3.0 -> satisfiable by laravel-notification-channels/webpush[3.0.0, 3.0.1].
To enable extensions, verify that they are enabled in your .ini files:
- /usr/local/php7.2.9/etc/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
提示我的PHP 7版本太高,不符合composer.json需要的版本,但是在PHP 7下应该也是可以运行的,composer可以设置忽略版本匹配,命令是:
$ composer install --ignore-platform-reqs
或者
$ composer update --ignore-platform-reqs
问题二.
说明:报关于php gmp扩展问题
$ composer install
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- mdanter/ecc v0.5.2 requires ext-gmp * -> the requested PHP extension gmp is missing from your system.
- mdanter/ecc v0.5.2 requires ext-gmp * -> the requested PHP extension gmp is missing from your system.
- Installation request for mdanter/ecc v0.5.2 -> satisfiable by mdanter/ecc[v0.5.2].
To enable extensions, verify that they are enabled in your .ini files:
- /usr/local/php7.2.9/etc/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
解决
说明:安装php gmp扩展库
$ yum install -y gmp-devel
$ cd /usr/local/php-fpm7.2.9/ext/gmp/
$ /usr/local/php-fpm7.2.9/bin/phpize
$ ./configure --with-php-config=/usr/local/php-fpm7.2.9/bin/php-config --with-gmp
$ make && make install
#在php.ini
加入:
extension=gmp.so
#重启php
/etc/ini.t/php-fpm restart
内存相关的报错
$ composer update nothing
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 28 installs, 0 updates, 0 removals
- Installing symfony/yaml (v3.4.23): The following exception is caused by a lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details
PHP Warning: proc_open(): fork failed - Cannot allocate memory in phar:///usr/bin/composer/vendor/symfony/console/Application.php on line 952
Warning: proc_open(): fork failed - Cannot allocate memory in phar:///usr/bin/composer/vendor/symfony/console/Application.php on line 952
[ErrorException]
proc_open(): fork failed - Cannot allocate memory
解决:
增加虚拟内存,重新再执行composer install or composer update nothing 就不会报错啦
$ dd if=/dev/zero of=/tmp/newdisk bs=1024 count=1024000
$ du -sh /tmp/newdisk
$ mkswap /tmp/newdisk
$ chmod 0600 /tmp/newdisk
$ swapon /tmp/newdisk