File Info PHP Error - Class 'finfo' not found but the module is in php.ini

Chris picture Chris · Sep 27, 2015 · Viewed 13k times · Source

I am having a problem getting File Info working. It is enabled in PHP.ini but when I run a php -m it is not listed. I have PHP 5.5 so it should be standard and not need the pecl. I am a newbie and confused so please be kind.

php -m

[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
ereg
exif
filter
ftp
gd
gettext
hash
iconv
imagick
imap
ionCube Loader
json
libxml
mbstring
mcrypt
mysql
openssl
pcre
Phar
posix
Reflection
session
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
XCache
XCache Cacher
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]
XCache
XCache Cacher
the ionCube PHP Loader

In my PHP.ini

extension = "fileinfo.so"

Answer

drew010 picture drew010 · Sep 27, 2015

By default this extension gets built in to PHP since 5.3, meaning there is no so to load.

Since it is not showing as an available module, it may mean PHP was compiled with the --disable-fileinfo switch (look at the Configure Command output in phpinfo) which would disable it from being included with PHP.

If it was compiled with the disable finfo option, you will either need to recompile PHP without that option, or compile and install the PECL module and then dynamically load the extension in php.ini.