Tag Archives: PHP

EC2 Guide: Software Configuration (6a / 7)

With most of the EBS volume work out of the way we can now configure the server to production standard. This means taming ClamAV, Amavisd-New, Spamassassin, Apache, PHP, MySQL, Dovecot, Postfix and Generating SSL certificates. This is likely the most important page in the guide!

EC2 Guide: Attach existing EBS volumes (5b / 7)

To make this guide complete I have included an upgrade path should you have previously followed it and wish to re-attach your existing, configured EBS volumes to a new server instance.

EC2 Guide: Create and attach new EBS volumes (5a / 7)

To allow our server to be upgradable we are going to separate out various parts of our system onto 3 separate EBS volumes so that they could be disconnected and re-attached to another machine very quickly should we want to add other servers.

EC2 Guide: Core Software Installation (4 / 7)

We should now be ready to install our core software on our Ubuntu 10.04 server and customise a few key things. We are going to add Postfix, Dovecot, Spamassassin, Amavisd-New, ClamAV, Apache, PHP, MySQL and a few other useful things.

Regex – match anything but a string

Regular expressions are something of a black art for programmers, and many get by without ever really learning them properly. Sure, most people will be able to use them to some level, but if you don’t use them for complex tasks in your day to day work you’ll never really need their advanced functionality. I

PHP Spinner Updated – Spin articles for SEO

Quite a while ago I wrote a post on spinning text using PHP to create lots of fresh content from one single block of marked up text. I actually had use for a nested version of this spinning code the other day so set about creating a more efficient version of my previous nested spin

Hierarchical Class Loading With Namespaces

A challenge often encountered when developing in PHP is the ability to instantiate a class from the highest point in a folder hierarchy where that class exists, but fall down the hierarchy when it is missing. This can be done using a factory class and reflection, but is not the most obvious thing in the world!

Using Google to Calculate Driving Distance / Time in PHP

A common problem for programmers is to calculate the straight line distance between two points given coordinates (lon / lat or easting / northing) and is trivial to solve. A less simple task is calculating the road distance between two addresses / postcodes / sets of coordinates.

But, as usual, Google can do this with ease and while it does not allow this functionality for every country in it’s API it is very simple to scrape the required information from their html service that they provide to everyone.

Dynamically Named Static Method Calls

Something that is being added in PHP 5.3.0 but is sorely missed in current versions is the ability to call a static class method from variables. It is something that is occasionally very useful (e.g. you have a validation class triggering other regional classes) and is already possible with standard class calls. Thankfully it’s very easy to simulate with eval…

Asynchronous cURL Requests

A possibly underused technique available to PHP developers is the ability to spawn a background PHP script without JavaScript. All you need to do this is the cURL library and a few lines of code. Let me explain, suppose you have a script that is going to take minutes (or longer) to run, you don’t want to sit looking at a blank screen, and your users certainly won’t! In this kind of scenario you can separate out that logic to a background file and leave your view free for other things, perhaps to query the database to see how the background process is doing?

Spin Text For SEO – A PHP Spinner

I recently had an SEO expert give us a few hours of his time to provide some suggestions to compliment our SEO strategy. One of the techniques that he introduced I was so impressed with (due to it’s utter simplicity) that I am kicking myself for not thinking of it before! Basically, if you have ‘doorway’ pages into your site (e.g. you have pages for ‘Cambridge Widgets’ and ‘Preston Widgets’ and alike) and want them to be dynamically generated, from the same content, but not to suffer horrible duplicate content penalties, you can use a ‘spinning’ function to generate contextually similar, different, content. The original concept is here, but I have enhanced it a bit to better suit my needs.

Validate E-mail Addresses

I know this is a topic with 1001 solutions, but I still get asked for an e-mail validation check from time to time, so here is one that I have used in the past. It’s a cut above average as it allows very basic validation, confirmation of a valid domain ending or even performs an MX record check to ensure that a mail server is at least set up for the domain in question.