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.1, 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.1, 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>;

Posted in category: Server Admin, Web Development | Tags: ,

Recovering a broken Subversion working copy

Posted 2nd December 2009 by Andy | No Comments

There are times when a Subversion working copy can mess up. This is usually due to human error, for example due to permissions problems or moving files or folders incorrectly

These can usually be easily recoverable, although at times it can seem there’s no solution. Here are a few examples and their solutions.
Continue reading Recovering a broken Subversion working copy »

Posted in category: Code Versioning | Tags: ,

Locked down authoritative versioned code repositories

Posted 12th September 2009 by Andy | No Comments

Centralised versioning systems are inherently authoritative, but when dealing with decentralised systems, either patches are made and applied to the maintainer’s repository, or one repository should be defined as the authoritative one.

If the authoritative repository requires commit access, it should be locked down as much as possible, requiring authentication, encryption, and push access without opening up raw file write access. If raw file write access is given, either intentionally or unintentionally, any user with access could corrupt or delete the repository.

Continue reading Locked down authoritative versioned code repositories »

Posted in category: Code Versioning | Tags: , ,

Git 1.7.0 on CentOS 5

Posted 1st September 2009 by Andy | 1 Comment

I’ve been hearing good things about git lately, with many projects which used to use subversion converting to it, so I’ve decided to try it out myself. RPMForge only has version 1.5, so like the other software I’ve been using, I’ve converted Fedora 11’s rpm to CentOS and put it in the Webtatic repository.

Update 2010-02-14 – Updated Git 1.6.6 to 1.7.0

Continue reading Git 1.7.0 on CentOS 5 »

Posted in category: Code Versioning | Tags: ,

Get an “A” in YSlow with Webtatic Optimizer

Posted 9th August 2009 by Andy | No Comments

The performance of a website is an important issue. Even fast responding dynamic pages can be hit with problems with sub-optimal static content such as high overhead on many HTTP requests and large javascript/css files. Tools like YSlow, and Google Page Speed help identify these problem areas.

Webtatic Optimizer is a tool that can be used to improve these areas, and can help get an almost perfect score.
Continue reading Get an “A” in YSlow with Webtatic Optimizer »

PHP public key cryptography using OpenSSL

Posted 5th July 2009 by Andy | 5 Comments

Recently I have been handling the security of some sensitive data. I had originally been encrypting/decrypting data with a symmetric-key system using mcrypt for PHP. This was due to the web frontend and the backend existing on the same server. However for security purposes I am now separating the frontend and backend onto different servers, so that there is no way the web accessible frontend, whether compromised or not, can get at the data it inserts into the database.

In order to do this, a asymmetric-key system is needed, such as public-key cryptography. Googling for examples of this in PHP, there doesn’t seem to be any results of this other than the php OpenSSL extension documentation, and systems that try to reinvent the wheel with their own implementations.

Using the PHP OpenSSL extension it is fairly easy to sort out a secure system for encrypting data with one key that only can be decrypted with another.
Continue reading PHP public key cryptography using OpenSSL »

Posted in category: Security, Web Development | Tags: ,