0%

Laravel创建项目报require ext-fileinfo错误

调用laravel new myapp创建项目时报错:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

_ _
| | | |
| | __ _ _ __ __ ___ _____| |
| | / _` | '__/ _` \ \ / / _ \ |
| |___| (_| | | | (_| |\ V / __/ |
|______\__,_|_| \__,_| \_/ \___|_|

Creating a "laravel/laravel" project at "./myapp1"
Installing laravel/laravel (v8.4.2)
- Installing laravel/laravel (v8.4.2): Extracting archive
Created project in D:\workspace\php/myapp1
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- laravel/framework[v8.12.0, ..., 8.x-dev] require league/flysystem ^1.1 -> satisfiable by league/flysystem[1.1.0, ..., 1.x-dev].
- league/flysystem[1.1.0, ..., 1.x-dev] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
- Root composer.json requires laravel/framework ^8.12 -> satisfiable by laravel/framework[v8.12.0, ..., 8.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
- D:\Program Files\php\7.3\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

解决方法:
出现此错误的原因是php.ini中的fileinfo扩展没有开启,开启 extension=fileinfo,再重新执行命令安装就可以了。