Webtatic.com

Just another technical blog

Facebook XHP RPM on CentOS

Posted 11th February 2010 by Andy | No Comments

A few days ago, Facebook released XHP, a PHP extension, which allows defining XML directly in PHP blocks, allowing you to “use PHP as a stricter templating engine”.

It seems a bit strange to be coding XML tags directly in PHP blocks, but it adds features such as automatic escaping, and the ability to manipuate the tags, and how they render.

I’ve compiled experimental RPMs, and put them in the Webtatic yum repository. These are compiled against PHP 5.3, which I also have in my repository.

I cannot guarantee the build of the exension is stable, as I had to add a few patches of my own to the source to get it to compile, so I don’t recommend you install it on a production site.

To install, first upgrade your PHP to 5.3, as detailed in my PHP 5.3 on CentOS post.

Then install the extension, and then you’re done:

yum install --enablerepo=webtatic php-xhp

To test if it is set up correctly, run the following:

php -r 'echo "XHP!\n"; exit; <a />;'

Currently XHP requires you to include a PHP file (xhp/init.php), which is installed in the include path, to define all the default elements e.g.:

require 'xhp/init.php';
 
$href = 'http://www.webtatic.com';
echo <a href={$href}>Webtatic.com</a>;

Related Posts

  • No Related Post

Leave a Reply