Setting up a LAMP stack on Amazon Web Services

After setting up a number of cloud servers within Rackspace, Peer1 and a few other cloud services, I decided I would set up an AWS (Amazon Web Services) EC2 server. I made this decision purely because they offer a free tier, which for someone who doesn’t have any high capacity websites running – is ideal. The only issue with choosing an EC2 server over the other options is that it requires a little more technical input to get up and running.

Getting Started

If you do not have an AWS account already, you can sign up completely free at http://aws.amazon.com/console/.

Once registered and signed in, we want to select the EC2 option, and press the big blue “Launch Instance” button.

Launching an instance

Once presented with the “Create new instance” wizard we can choose the “Classic wizard”.

On the next screen we will be asked to select which AMI (Amazon Machine Image) we would like to install. For this we will choose Ubuntu 12.04.1 LTS (64 bit).

For the instance details section, we will launch only 1 instance, and I have selected the T1 Micro (Free) instance type. I have also left the Availability zone as “No Preference” but if you require you’re server in a specific area of the country – you can amend this as required.

We can then continue straight past the Advanced options, Storage configuration and Tags as the defaults settings will work perfectly for us at the moment.

When we reach the Key Pair section, we want to create a brand new Key Pair. This is used to authenticate your computer with the EC2 server instance. You can fill out the Name field to anything that you wish. Once named, we want to download the keypair.

For the next step we will choose the ‘quick-start-1′ security group. Then we can launch the instance.

After a few minutes we will see that we have 1 running EC2 instance.
Continue reading

The Factory Pattern: The good, the bad and Magento

I my opinion, the one thing that separates a software engineer from a script kiddy is design patterns. The knowledge of separation of concerns and abstraction through different patterns is what makes an application manageable, extendible and efficient (from a development point of view).

Whilst working with Magento over the last year or so, one pattern that crops up in 90% of the development is the factory pattern.

The factory pattern is an incredibly useful pattern, allowing the application to decide which class is to be instantiated whilst the application is running.

Most commonly seen in Magento as:
Mage::getModel("module/model");

Although the factory pattern is an incredibly useful tool, It is completely overused in Magento. The whole application is riddled with factories and this wouldn’t usually be a bad thing, until you try and do something like constructor injection.

My personal development habits tend to favour constructor injection which makes Magento’s practices less than ideal. Of course you could create your own setup function, but this can’t be enforced on instantiation and isn’t obvious for an outside developer to call.

Some other developers that I have encountered tend to favour using the entire class namespace, but this is often frowned upon by the Magento core development team and prevents module extension.