Developing software in the Real World

Adding Diff syntax highlighting to Sublime Text

My chosen colour scheme for Sublime Text doesn't include support for diff/patch files, so I added my own. To the bottom of my .tmTheme file, I added this just above the closing </array>:

This sets up a green colour for the meta information, blue for added lines, red for deleted lines and a yellowish colour for changed.

Simple logging of ZF2 exceptions

I recently had a problem with a ZF2 based website where users were reporting seeing the error page displayed, but I couldn't reproduce in testing. To find this problem I decided to log every exception to a file so I could then go back and work out what was happening. In a standard ZF2 application, the easiest way to do this is to add a listener to the 'dispatch.error' event and log using ZendLog. To… continue reading.

Notes on embedding fonts in rst2pdf

I wanted to use Helvetica Light in a PDF that I'm creating using rst2pdf and this proved a little tricker than I expected. Note that to use fonts with rst2pdf, you need to install fontconfig using brew:

Now, on to the problem! In this case, I discovered that setting stdFont: Helvetica-Light or stdFont: HelveticaLight in the style file resulted in Verdana being used in the PDF file! Fortunately, the -v switch to rst2pdf is… continue reading.

Setting the umask when using Capistrano

This is one of those posts to remind me how I solved a problem last time! I've recently been using Capistrano for deployment and other remote tasks and it's proving quite useful. One problem I ran into was that the umask was being set to 022 when using Capistrano and 002 when I was ssh'd into the server itself. After a bit of research, I discovered that the secret is to put the umask statement… continue reading.

Minding my own business

After nearly ten fantastic years at Big Room Internet, I have decided to take the jump and run my own business! Having concentrated on project management for the last year or so, I am happy to return to hands-on development. I also intend to provide training and consultancy services. I'm really excited by this new phase of my career. I have created a shiny new company for interesting projects: Nineteen Feet Limited. If you want… continue reading.

Objects in the model layer: Part 2

I previously talked about the terms I use for objects in the model layer and now it's time to put some code on those bones. Note that,as always, all code here is example code and not production-ready. An entity My entities are plain old PHP objects:

There's nothing particularly complicated here. We have an object with a number of properties and some methods. This object represents a book, so we have properties of author,… continue reading.

Ideas of March: It's my content and my opinion

If there's one thing Twitter is not good at, it's holding a discussion on something controversial. Sean Coates noted this problem when he said: "I'm not worried about having my opinion disagreed with; I *am* concerned that I will be crucified for something I don't mean." I suspect this is because you don't have the space to develop an idea on Twitter. It also doesn't help that Twitter is a conversation which means that people… continue reading.

Objects in the model layer

I currently use a very simple set of core objects within my model layer: entities, mappers and service objects. Entities are objects that represent something in my business logic. For example, in my traditional Album's tutorial, the entity would be the object that holds one album. It has properties such as title, artist and date created and methods that are specific to this entity. Mappers know how to save and load an entity from the… continue reading.

Changing the format of a ZendForm DateTime element

If you want to change the format of the value of a DateTime element, the easiest way to do this in your Form class is to do this:

The two things to note: You can't set the format within the array – it has to be via a setFormat() call. If you change the format, you must set the min attribute in the same format, as otherwise it will try to set it with… continue reading.

Improved Sublime Text 2 PHP getter and setter generation

As I've been using Sublime Text 2 for all coding for the last year, I've noticed a significant problem with my simple 'getset' snippet that I created last year: it doesn't handle underscores in property names correctly. I've finally got around to fix it! As with a lot of editors, Sublime Text supports snippets which are essentially text expansions of a short phrase into more text. This snippet creates a getXxx() and setXxx() method from… continue reading.