Pragmatism in the real world

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: namespace Book; class Entity { protected $id; protected $author; protected $title; protected $isbn; public function __construct($data = array()) { $this->populate($data); } // Data transfer methods public function populate($data) {… 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: $this->add(array( 'name' => 'next_appointment', 'type' => 'ZendFormElementDateTime', 'options' => array( 'label' => 'Next callback time', ), 'attributes' => array( 'min' => '1 Jan 2013, 00:00', ), )); $this->get('next_appointment')->setFormat('j M Y, H:i'); The two things to note: You can't set the format within the array – it has… 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.

Thoughts on module directory structure

I've been working on a Zend Framework 2 module within a larger project that doesn't have that many PHP class files. Specifically, it has a controller, a mapper, an entity, a service and a form. As a result, the traditional Zend Framework 2 directory structure for the Account module looks like this (with class names in brackets): module/ Account/ config/ src/ Account/ Controller/ CaseController.php (Account\Controller\CaseController) Entity/ CaseEntity.php (Account\Entity\CaseEntity) Form/ CaseForm.php (Account\Form\CaseForm) Mapper/ CaseMapper.php (Account\Mapper\CaseMapper) Service/… continue reading.

2012 in pictures

As another year draws to a close, I continue my tradition of showing off some photos that recap our year as I have done in 2008, 2009, 2010 and 2011. January January 2012 was a quiet month. I released Daily Jotter 1.3 and started using Sublime Text as my editor of choice for programming. Photographically, the highlight of the month was the Worcester Flickr Group's scavenger hunt. February It snowed in Feburary and I started… continue reading.

Zend Framework 1 is not dead; ensure you upgrade!

I'm delighted to announce that Zend Framework 1.12.1 has been released! This release fixes 50 issues which is a great result. I'd like to thank everyone who submitted a patch to ZF1 and to Matthew Weier O'Phinney, Frank Brückner and Mike Willibanks in particular for their work on this release. There's a few important things to note: There's a security fix in 1.12.1. Please read ZF2012-05 if you use Zend_Feed_Rss or Zend_Feed_Atom. The minimum PHP… continue reading.

Some notes on git

This set of notes covers the main things that I think you need to know about working with git. It is not comprehensive and mainly serves as a reminder for myself. Remotes In a typical open source workflow using GitHub or BitBucket, you would fork the main repository into your own and then clone that copy to your local computer: git clone git@github.com:akrabat/joind.in.git You then need to connect your local repository to the main repository.… continue reading.