Skip to content

PHAR and FreeBSD

I noticed that archivers/pecl-phar vanished from the ports tree on one of my FreeBSD servers.


Reasons to remove the port were:

  • the port is unmaintained
  • the port was based on the outdated phar extension from pecl
  • phar (in pecl) contains open security issues

The simple solution is to create a new port which of course will use the phar which is bundled in PHP's core. And I will get to that (but feel free to beat me at it ;-)).


In the meantime, here's a simple solution to get phar on FreeBSD.

At first, make sure you're running PHP 5.3.8 (installed from lang/php5). Then fetch the PHP source and compile the phar extension only.

foo# fetch
foo# tar zxvf php-5.3.8.tar.gz
foo# cd php-5.3.8/
foo# ./configure --disable-all --enable-phar=shared
foo# make

If all goes well the modules/ directory contains a file (among other phar-things).

The remaining steps are to copy to your extension_dir and load it in extension.ini:

foo# cp modules/ /usr/local/lib/php/20090626/

Feel free to double-check the location of directory:

foo# php -r 'echo ini_get("extension_dir");'

Finally, make sure PHP loads far by adding the following to /usr/local/etc/php/extensions.ini:


That's all. Once you restart php, or your webserver, phar should show up in phpinfo().

And as soon as a new php5-phar port is added (probably in archivers), you should make sure to delete and also remove the line added to the .ini.


No Trackbacks


No comments

The author does not allow comments to this entry