Sublime Text 2 Snippet for PHP getter and setter generation

3rd January 2012

I've been playing with Sublime Text 2 recently and have quite enjoyed how quiet my ageing laptop is when the fans aren't running due to a Java-based IDE.

As with a lot of editors, Sublime Text supports snippets which are essentially text expansions of a short phrase into more text. I needed to create a few getXxx() and setXxx() methods for some properties of a class and decided that the easiest way to do this would be with a snippet.

To create a snippet, go to Tools->New Snippet... and replace the code example provided with this:


<snippet>
    <content><![CDATA[public function get${1/(.*)/u$1/}()
{
    return $this->${1:$SELECTION};
}

public function set${1/(.*)/u$1/}($$1)
{
    $this->$= $$1;
    return $this;
}
]]></content>
    <!-- OptionalTab trigger to activate the snippet -->
    <tabTrigger>getset</tabTrigger>
    <!-- OptionalScope the tab trigger will be active in -->
    <scope>source.php</scope>
    <!-- OptionalDescription to show in the menu -->
    <description>Create getter and setter methods</description>
</snippet>

Save the file as getset.sublime-snippet and you're done.

To use, simply type getset followed by tab (in the latest dev builds, at least) and it will automatically expand. Alternatively, select some text and use shift+cmd+p -> getset to automatically replace the selected text with the get and set methods completed for the text that was selected.

2011 wrap up

31st December 2011

As I have done in 2008, 2009 and last year, I thought I'd continue my tradition of recapping my year.

January

PHPBNL 2011 happened in January. Also, my Mac OS X application, Daily Jotter was released onto the Mac App Store.

My app is on the Mac App Store!

February

The first PHPucEU happened in Manchester which was great fun and, of course, the PHPUK conference in London. The biggest news for us though, was that we moved house in February!

We have keys to the new house!

March

I went to Canada for the rather excellent Confoo conference and watched a snowball fight!

Snowball fight!

April

A relaxed month after 3 months of conferences and a house move. There was a Royal wedding in the UK which resulted in a lot of merchandising!

Paraphenalia

May

May was the busiest month ever. Both sons have their birthdays in May and DPC in Amsterdam and php|tek in Chicago are back to back conferences! So many good photographs this month, but I have gone with this one of Jeremy Kendall as he took many excellent photographs at tek!

Here's looking at you!

June

Our trip to the zoo this year was in June when we went to Twycross Zoo.

Lemur

July

We went to the beach in July.

On the beach

August

In August we went to the Fleet Air Arm Museum.

Fleet Air Arm Museum

September

My eldest son achieved his Grade 1 classical guitar certification this month. We also went to a friend's wedding.

Confetti

October

October saw the very excellent PHPNW conference return for its forth year and I was very glad to be asked to do a ZF2 tutorial which seemed to go well.

Rick and Jeremy

November

November was the month that John Arnold held his creativityex project. I particularly liked my effort for negative space:

Shoes

December

Last month of the year and as part of the Worcester Flickr group, I got to take a photograph in a studio!

Elephpants

All in all, a pretty good year. One interesting thing I did notice was that I have a lot more good photos sitting in Aperture than I published. I think this is because Aperture is so slow to use on my old Macbook Pro. I was better at publishing photos with Capture NX2 and I thought that was slow; Clearly it wasn't that bad!

Zend Framework 2 Beta 2 released

21st December 2011

Zend Framework 2, Beta 2 has been released!

The key new features are:

  • Refactored Mail component
  • Refactored Cache component
  • MVC updates

Check out Matthew's blog post for the full details.

I've also updated my tutorial. This is a good time to get involved, try it out and let us know what you like/dislike.

Updated tutorial for Zend Framework 2 beta 1

18th October 2011

With the announcement of Zend Framework beta 1, I have updated my venerable tutorial to work with it!

Getting started with Zend Framework 2 (beta1), creates the same application as my ZF1 tutorial, so it should be very familiar, but this time, it's in the context of Zend Framework 2. As usual, it's a PDF too.

Please download it, try it out and let me know if you find any typos!

Bring a laptop to my ZF2 tutorial at PHPNW11

5th October 2011

If you are attending my ZF2 tutorial at the PHPNW11 conference on Friday, I thought I'd remind you that you may find it useful to bring a laptop.

Ideally, your laptop should be set up with PHP 5.3 and MySQL and a working copy of my ZF1 tutorial. It would be a good idea to have a vhost set up on http://zf2tutorial.localhost or similar. Ability to create additional vhosts may come in handy. The PHP cli tool should also work as you'll need to run some php scripts from the command line.

I'm going to be covering ZF2's autoloader, dependency injector, event manager and then we'll go through the current Mvc prototype. We'll also be doing some exercises if we have time.

I'm looking forward to it and hope you are too!