Installing Memcached for MAMP PRO 1.9 running php 5.3.2 on OSX

After a few tedious hours of trying to install memcached for Mamp on my 10.6.8 based Mac, I finally found a solution. This has been sourced from a number of places and I hold no warrant for it working for you. This has, however worked for me, so thought i’d post a quick how to. I’m no expert on how this works, so am unable to diagnose any issues you have.

The setup I have is:

  • Mac OSX 10.6.8
  • MAMP PRO 1.9
  • PHP 5.3.2

As i’m a it of a CodeIgniter nut, i’ve been using this Memcached library (default settings work out of the box).



Sendgrid and CodeIgniter

I’ve recently been working on a new project that focuses around the sending of email for marketing purposes – not a newsletter project, but something a bit more advanced.

Without going into too much detail, the system allows users to upload assets and combine these assets to create a one page promotional site. The system also allows users to create lists of recipients and send an email out to this list with a unique URL to view a customised promotional page.
The recipient lists could be as small as 10 or as large as 500, so sending the email from our server wasn’t an option from a performance point of view. In addition we needed to collect analytics (open and views) on the emails. As these emails were for marketing purposes it was important to see how effective they were, for this we needed to know if it had been delivered, opened or had bounced.

We looked at a few services for sending email and decided to use Sendgrid for various reasons; the robust smtp and rest api’s, analytics support and price.

The SMTP api was especially significant to us, as it allowed us to make one api call to send any number of emails. The beauty lay with a custom header that gets sent with the email. This header contains a JSON object of various parameters which meant that we could construct our recipient list, and customisable variables (such as name and link) and send this with our email content only once. Sendgrid would then seamlessly take care of sending the mail out to our recipients with the correct content on our behalf.
As we were building the app using CodeIgniter, using the SMTP api meant that we could use the built in mail class without needing to implement many code changes. There was however one downside in that the class by default doesn’t allow you to set your own custom headers. A bit of tweaking later and I had added a new function that allowed me to pass in custom headers.

public function add_custom_header($header,$content){
return $this;

I also built a library (based on the PHP example provided by Sendgrid) that allows you to easily add and manage the content of these headers (which I’ll put on github once it’s a bit more polished).

Rather than build a whole library, I combine the creation of the headers with the default mail class which meant that sending out emails was fairly straightforward.

The second aspect of Sendgrid that appealed to us was the various api’s, especially the event api. This allows you to set a notification URL, and the listen out for events. This was great for us as we could get; deliveries, opens, bounces, spam reports and clicks in realtime. The info was posted to a controller which allowed us to easily log the data.

If you’re thinking of integrating with a 3rd party service to send email, i’d definitely recommend using Sendgrid.

Go take a look at the simple example I have put together over on Github.


Just a quick blog post to promote HydraHack, organised by Tom Martin (also of @383project fame).

HydraHack is a monthly meetup for web developers in Birmingham, who enjoy getting together and making things.

If you’re Birmingham based, you should pop along, and if nothing else say hi!

Hello World

I’ve decided to move things around a bit with regards to the name of the blog, and the hosting solution (more on that in a later post).

After all this blog is all about me, and the code that I write, both at work for 383project aswell as personal projects such as my beanstalk command line interface or Geckoboard CodeIgniter library. The whole sizzla thing was left over from Uni, when one of my projects involved creating an online music store for a fictional record label – Sizzla Records.

So, a new name and a new host (this blog is now hosted with @phpfog), but still the same content.

Beanstalk Command Line Interface

It’s fair to say that we love a bit of Beanstalk (affiliate link, gets you 10% off) at @383project. I’ve built tools to help you integrate with Geckoboard, display Growl notifications of your commits and a webapp for deploying and checking your repos. Fellow dev Andy Yates has gone way further and built a native iOS application called MagicBean.

We use Beanstalk on a daily basis, and it forms the centre of our workflow. Developers can easily collaborate on projects, and then when ready seamlessly deploy to a server.

Because of this, we have created a workflow for setting up new web projects which goes a little something like this:

  1. Create a Staging environment on our staging server
  2. Create a Production environment on our production server
  3. Create a Beanstalk repo, and add the staging and production server details
  4. Work on our code and commit (changes get automatically deployed to staging)

Step 3 is the part that is most tedious (we use Plesk on our server so 1 & 2 are pretty straight forward).

As almost every site we build will be staged on our development server on a subdomain of our development domain, the FTP details are always the same (apart from the document root), it seems silly to manually enter these details everytime we need to create a new repo.

Also as most sites are also hosted on our dedicated server the only details that change per site will be the FTP username and password.

This got me thinking; wouldn’t it be great to be able to type

$ beanstalk repo:create test_repo green

And have a Beanstalk account created with trunk, branches and tags set up, aswell as a Staging Server with automatic deployments and a Production Server with manual deployment.

I had a quick search and couldn’t find anything so decided to use the Beanstalk API along with php to write my own wrapper. After taking inspiration from Fire – a command line tool for CodeIgniter, I came up with my Beanstalk command line tool.

This is fairly specific to our own use case at 383project, so I decided to add a few more functions for general use.

Take a look at the source on Github and have a play, i’d love to hear if you manage to use it to save time in your own work flows.


To use the tool, first download the source from Github, open it up in a text editor and fill in your Beanstalk details. If you plan on using the tool to create release servers then scroll down to line 281 and edit the code with your own server details and then again at around line 339.

Place the file somewhere in your path, or create a folder called bin, in your home directory and add it to your path:


Then make the script executable by typing

chmod a+x beanstalk

You should then be able to use

$ beanstalk repo:create test_repo green

To make your life a tad easier!

You can also deploy by typing

$ beanstalk repo:deploy REPO_NAME

You’ll then be prompted through the steps to deploy your code!