用composer 创建thinkphp项目,环境是php8.1.21,创建thinkphp6项目成功,创建thinkphp8项目时出现下面错误:
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- league/flysystem[2.0.0, ..., 2.5.0] require league/mime-type-detection ^1.0.0 -> satisfiable by league/mime-type-detection[1.0.0, ..., 1.11.0].
- topthink/think-filesystem[v2.0.0, ..., v2.0.1] require topthink/framework ^6.1 -> found topthink/framework[v6.1.0, ..., v6.1.4] but it conflicts with your root composer.json require (^8.0).
- league/mime-type-detection[1.0.0, ..., 1.3.0] require php ^7.2 -> your php version (8.1.21) does not satisfy that requirement.
- league/mime-type-detection[1.4.0, ..., 1.11.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
- topthink/think-filesystem v2.0.2 requires league/flysystem ^2.0 -> satisfiable by league/flysystem[2.0.0, ..., 2.5.0].
- Root composer.json requires topthink/think-filesystem ^2.0 -> satisfiable by topthink/think-filesystem[v2.0.0, v2.0.1, v2.0.2].
To enable extensions, verify that they are enabled in your .ini files:
- D:\php\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-fileinfo` to temporarily ignore these required extensions.
解决方法:
出现此错误的原因是php.ini中的fileinfo扩展没有开启,开启 extension=fileinfo,再重新执行命令安装就可以了。
也就是把 php.ini里面的 ;extension=fileinfo 这一句前面分号去掉,开启了就可以了。