我有ext-fileinfo但是Composer说它丢失了

Web*_*nan 19 php laravel composer-php

我正在尝试安装Laravel包干预图像,当我运行时composer update:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - intervention/image 2.0.5 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - intervention/image 2.0.4 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - intervention/image 2.0.3 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - intervention/image 2.0.2 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - intervention/image 2.0.1 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - intervention/image 2.0.0 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - Installation request for intervention/image 2.* -> satisfiable by intervention/image[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5].
Run Code Online (Sandbox Code Playgroud)

我有php 5.4 php.ini,并在phpinfo()以下内容中启用了扩展名:

                    fileinfo

fileinfo support                  enabled
version                           1.0.5
Run Code Online (Sandbox Code Playgroud)

并重新启动apache ...但仍然没有运气.

小智 33

Windows用户:只需编辑php.ini和取消注释此行:

extension=php_fileinfo.dll
Run Code Online (Sandbox Code Playgroud)

记得重新启动Apache以使新的php.ini生效.


Web*_*nan 20

显然,这是因为php.iniweb/apache和CLI 有单独的文件,因为composer使用CLI而phpinfo()使用main php.ini发生问题.

如果您php -m在CLI中运行并且没有看到模块的名称,您应该找到CLI php.ini(在我的情况下php-cli.ini并添加扩展名.例如extension=php_fileinfo.dll


小智 12

我也有同样的问题.现在修复了.
你也可以取消注释这一行

extension=php_fileinfo.dll  
Run Code Online (Sandbox Code Playgroud)

在以下文件中:

  1. php.ini-development
  2. php.ini-production

请不要忘记restart你的Apache.
希望这会有所帮助.

  • 该答案已经由其他用户提交。 (2认同)

flo*_*w3r 7

对我来说,使用 php 7.4.x 和 Windows 10 是不同的。

我检查php.ini了 PHP 在 CLI 模式下使用的文件php --ini.

它显示了C:\php7\php.ini- 我以前解压缩 PHP 的地方(并且还指出 Composer 那里)。

然后我需要在那个文件中取消注释 extension=fileinfo