I have been pulling my hair out this morn­ing try­ing to get the PHP File­info exten­sion work­ing under PHP 5.2.14 on Win­dows Server 2003 SE. Actu­ally, to be accu­rate: I’ve been try­ing to get the PHP File­info exten­sion work­ing; the pulling out of hair is a nor­mal occur­rence when doing any­thing on a Win­dows server, I am learn­ing.

Last week I ended up installing PHP 5.2 rather than 5.3, all because I read that the LDAP exten­sion wasn’t yet avail­able for 5.3 on Win­dows. Then this week it looks like File­info is avail­able for 5.3 but not 5.2! Why oh why did I agree to move to a blasted Win­dows machine from my nice well-setup and work­ing Ubuntu box?!

Any­way, I tried to install File­info from PECL (with the same result with both the pecl and pear com­mands):

D:>pear install pecl/fileinfo
WARNING: "pear/Fileinfo" is deprecated in favor of "channel://php-src/ext/fileinfo/in php sources"
downloading Fileinfo-1.0.4.tgz ...
Starting to download Fileinfo-1.0.4.tgz (5,835 bytes)
.....done: 5,835 bytes
3 source files, building
ERROR: The DSP Fileinfo.dsp does not exist.

PECL bug #12603 is about this prob­lem, but is still open and was no help.

The solu­tion:

I’ll skip the details of the loops and dead­ends I tra­versed in try­ing to fix this. There were dif­fer­ent PHP ver­sion, dif­fer­ent DLLs, and any num­ber of forums and Scroogle searches, but ulti­mately I:

  1. went down the list of old PHP releases to the most recent 5.2 release that had a sep­a­rate Col­lec­tion of PECL mod­ules; this was 5.2.5, and I down­loaded it;
  2. copied the php_fileinfo.dll from pecl-5.2.5-Win32.zip and put it where all the other exten­sions live;
  3. added the extension=php_fileinfo.dll line to php.ini; and
  4. restarted Apache.

So sim­ple, and mag­i­cally every­thing now works! So I thought I’d post this here, in case any­one else’s hav­ing the same prob­lem. I’ll add a note to that bug report too.

[7 comments] [Keywords: , , , ] [Permanent link]


  1. Sam Wilson says:

    One other thing that I’ve done, in order to use code writ­ten for 5.3 (specif­i­cally Kohana’s File::mime() method), is:


  2. Francisco says:

    Cheers mate, you saved the lit­tle left of my hair. ta

  3. John says:

    Sam, I’m try­ing to get the php_fileinfo.dll set up using win­dows 7, IIS 7.5, PHP 5.2.17.
    have you had any luck, or com­ments from folks with this issue using IIS?

    I’ve fol­lowed your advice above and have had no luck get­ting the file to actu­ally load.

    I get a 500 error with this in the log:
    PHP Warn­ing: PHP Startup: Unable to load dynamic library ‘C:\Program Files (x86)\PHP\v5.2\ext\php_fileinfo.dll’ — The spec­i­fied mod­ule could not be found.
    in Unknown on line 0

    push me in a new direc­tion. please.

  4. Sam Wilson says:

    @John: I assume the file is actu­ally at C:\Program Files (x86)\PHP\v5.2\ext\php_fileinfo.dll? If it is, I’ve no idea why PHP can’t find it, sorry! Per­haps some per­mis­sions prob­lem on that par­tic­u­lar file? I gave up try­ing to use IIS ages ago; it’s too con­fus­ing, and I’d rather keep my Apache skills—they’re use­ful in more places… :-)

  5. Brent says:

    This is a bug in the PEAR scripts that has been going on for years.

    This bug is the root cause of the prob­lem: http://pear.php.net/bugs/bug.php?id=17016

  6. Hi, the whole thing is going well here and ofcourse every one is shar­ing infor­ma­tion, that’s
    actu­ally fine, keep up writ­ing.

  7. Where to get your­self the same?,

Leave a Reply

Your email address will not be published. Required fields are marked *