Monday, November 22, 2010

Enabling internal PHP fileinfo on FreeBSD

In a previous post (Upgrading to PHP 5.3 ...), I mentioned a PECL extension pecl-fileinfo-1.0.4

Apparently, installing that extension was a wrong move. The manual says:
This extension is enabled by default as of PHP 5.3.0. Before this time, fileinfo was a PECL extension but is no longer maintained there. However, versions prior to 5.3+ may use the  discontinued PECL extension. 
 Indeed, the PECL version did not work as expected, so I uninstalled it.

Then I discovered that on FreeBSD the internal version of fileinfo was NOT enabled by default.

Here is the relevant part of Makefile found in /usr/ports/lang/php5:
                --with-layout=GNU \
                --localstatedir=/var \
                --with-config-file-scan-dir=${PREFIX}/etc/php \
                --disable-all \
                --enable-libxml \
                --with-libxml-dir=${LOCALBASE} \
                --with-pcre-regex=${LOCALBASE} \
                --with-zlib-dir=/usr \

 I created a Makefile.local file with just one line

After rebuilding PHP, this test showed that fileinfo is enabled:
$ php --rf finfo_open
Function [ function finfo_open ] {

  - Parameters [2] {
    Parameter #0 [ $options ]
    Parameter #1 [ $arg ]