问题原因:
laravel项目执行 composer install时报错,报错信息如下:
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- hhxsv5/laravel-s is locked to version v3.7.0 and an update of this package was not requested.
- hhxsv5/laravel-s v3.7.0 requires ext-pcntl * -> it is missing from your system. Install or enable PHP's pcntl extension.
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-pcntl` to temporarily ignore these required extensions.
google 结果:Process Control support in PHP is not enabled by default. You have to compile the CGI or CLI version of PHP with --enable-pcntl configuration option when compiling PHP to enable Process Control support.
大意就是这个配置默认是不被开启的,需要在编译php的时候使用 --enable-pcntl 参数开启
从https://www.php.net/releases/网站下载7.3.22版本源码在本地mac上编译,结果编译过程报错;后续原因没有继续追查,感觉以目前认知解决比较困难;
因此整理了一下比较不需要底层信息的解决方式:
仅针对mac 且 php version = 7.3
具体操作如下:
1.使用brew search php 查找brew 支持的php版本
2.执行brew install php@7.3
如果执行报错:那么google php 第三方brew资源库
执行brew tap shivammathur/php
重新brew search
注:shivammathur/php 是我当时搜到的可用的资源
3.将brew install 之后的php@7.3添加到环境变量中
export PATH="/usr/local/opt/php@7.3/bin:$PATH"
export PATH="/usr/local/opt/php@7.3/sbin:$PATH"
export LDFLAGS="-L/usr/local/opt/php@7.3/lib"
export CPPFLAGS="-I/usr/local/opt/php@7.3/include"
4.使用php -v验证添加之后的php版本信息
5.再次执行composer install显示成功
其中遇到的问题:使用这个第三方库安装php@7.0 直接执行php命令报错;安装php@7.3可用