// 07.Feb.2010

PHP Caching to Speed up Dynamically Generated Sites


// 31.Dec.2009

10 WordPress Dashboard Hacks

A large part of my professional work involves the build and deployment of WordPress-based websites. Now as any designers/developers among you will appreciate, it can be extremely annoying frustrating to sign off a build only to come back later to see that your client has (inadvertantly) messed things up because WordPress has placed too much power in their hands.

I was delighted then to read “10 WordPress Dashboard Hacks” because there are some really useful code snippets presented therein:

  • Remove Dashboard Menus: At last I can remove certain menus from the client’s view — whilst obviously still leaving full control for the Admin user
  • Define Login and Dashboard Logos: Great for branding.
  • Disable the “Please Upgrade Now” message: I never want my clients to do this. I think this is one of my responsibilities.
  • Customise Dashboard Widgets: Again, it’s about keeping control. Not exposing the client to things which could be hazardous.
  • Provide Help Messages: Because they’re helpful (if done correctly).

Some of these are definitely going to be rolled out on to some of my client’s sites in the near future.


// 22.Nov.2009

Accelerating My WordPress Installation (Redux)

Ferrari 612 Scaglietti

A long time ago, in a galaxy far, far away… oh sorry, wrong script. I’ll start over. In the dim and distant past, I wrote about my efforts to eke a little bit more performance out of the WordPress installation that this glorious website runs upon. What I’d done was fairly basic: content compression, reduced page weights, database tuning… the usual stuff.

I also described how I’d failed to get WP Super Cache working and wrote that I was investigating PHP accelerators. Yet, despite my endeavours, the website’s performance continued to be, well, pitiful. Some time later I managed to get WP Super Cache working and things improved, but were still disappointing to me.

I come from a mod_perl background and one of mod_perl’s strengths is the speed at which it can run its applications. The PHP app’s that I now find myself working with just can’t compete. I believed that I’d just have to accept that the performance goals I was aiming for weren’t achievable.

However, I was recently forced to reconsider my position when I was contracted to build a website on top of the Zend Framework — because, despite being written entirely in PHP, nursesstore.co.uk turned out to be very fast.

Suddenly, I knew that it was possible to build fast PHP applications. So I turned my attention, once again, to the speed-deficient Urban Mainframe with the fire of the true zealot burning in my eyes.

Continue Reading…


// 21.Nov.2009

Installing APC on Media Temple Grid Server

For some time now I’ve been wanting to install the Alternative PHP Cache (APC) on the Media Temple GS server upon which this website is hosted. Tantalised by the performance improvements that I’ve read about, APC became my Holy Grail. But I couldn’t get it to install on the GS server, until now.

I’ve documented the steps I used to get APC running here, in case they’re useful to anyone else.

  1. Telnet or SSH onto your GS server
  2. mkdir /home/#####/data/lib (where “#####” is your Media Temple account number)
  3. mkdir /home/#####/data/lib/php
  4. wget http://pecl.php.net/get/APC-3.0.19.tgz (at the time of writing, this is the latest stable version - adjust as necessary)
  5. tar zxvf APC-3.0.19.tgz (again, adjust as necessary)
  6. cd APC-3.0.19
  7. phpize5
  8. ./configure --enable-apc --enable-apc-mmap --with-apxs2=/usr/sbin/apxs --with-php-config=/usr/local/php-5.2.6-1/bin/php-config
  9. make clean
  10. make && cp modules/*.so /home/#####/data/lib/php
  11. Finally, add the following code to your php.ini file:
    extension_dir = /home/#####/data/lib/php/
    extension = apc.so

That’s it. APC should now be installed and you should be able to measure a significant improvement in your PHP script performance.


// 25.Oct.2009

Working Under the Hood

Code Folding
Photo Credit: Syntax Error - Folded Up Beyond All Recognition by Simon Pow

Oh the weather outside is frightful
By my Mac it’s so delightful
Sign on to my WordPress node
Hack the code, hack the code, hack the code


Er, sorry about that folks (and Mr. Brooks). So I’ve spent my weekend fooling around with WordPress plug-ins and enjoying some hard-core coding action with a hot PHP interpreter. The results of which, are a handful of new features on this site, a few little things that should make your stay here even more rewarding than it already is (I know, I know – that hardly seems possible – but I’ve managed it, superstar hacker that I am.)

Continue Reading…


// 17.Oct.2009

CSScaffold

Scaffold is a new type of CSS framework, built with PHP, that allows speed up your development time by doing the hard work for you. It is different to other CSS frameworks, like Blueprint and 960.gs, but it’s power lies in it’s ability to extend the CSS language. You can even generate the CSS found in other CSS frameworks dynamically, like grid classes to quickly build layouts.


// 16.Oct.2009

Recess PHP Framework

Now this looks interesting. Recess is a PHP development framework based on the Model-View-Controller principle.

  • Tools Included for Every Developer
  • Declarative PHP with Annotations
  • Stays out of your way, not in it
  • Create RESTful APIs with Ease
  • D.R.Y. in Philosophy & Practice
  • Caching-Oriented Architecture
  • Open Source under MIT License

// 05.Oct.2009

Dynamic Grayscale Conversion with PHP and GD

A powerful grayscale function for use with the GD graphics library — one that is both easy to use, and customizable. Most grayscale functions typically average the red, green, and blue values of each of an image’s pixels, then set each RGB value to that average. This grayscale function can do that, too, and it works fine — but it is also able to take account of the relative amount that each color contributes to a pixel’s intensity. As a result, pixels that are disproportionately weighted toward one color contribute more to the total intensity than if they tended to neutral — something altogether lost if simply averaging. As a further option, the results of both processes can be blended to produce a weighted average, and arguably the best final image.


// 30.Aug.2009

For Your Eyes Only

Here’s a small but incredibly useful snippet of code I’d like to share. When I’m developing WordPress websites, I often find myself in a situation where I need to code on a site that’s actually live. Naturally I want to keep my prototyping invisible to the visitors of that site. After all, I don’t want anyone seeing all my mistakes now do I?

The following wrapper can be applied to a block of code and the results will only be visible on the live site to users who are logged in with admin privileges.

Continue Reading…


// 30.Aug.2009

A Window into the Archives (Part 2)

In this article I’m going to present the PHP code I wrote for the Window into the Archives module that currently adorns the sidebar on this website. I described the rationale behind the module in an earlier essay.

Continue Reading…