Skip to content

PHAR and FreeBSD

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

Problem?

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 ;-)).

Solution

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 http://de2.php.net/get/php-5.3.8.tar.gz/from/de.php.net/mirror
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 phar.so file (among other phar-things).

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

foo# cp modules/phar.so /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:

extension=phar.so

Fin

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 phar.so and also remove the line added to the .ini.

Trackbacks

No Trackbacks

Comments

No comments

The author does not allow comments to this entry