I’ve mixed feelings about the PSR standards to date.

  • PSR-0 has standardised autoloading in a practical way. Sure, it does have an evil design flaw (different classes can map to the same file on disk), but in practice it’s not a problem that happens.
  • I’d have personally liked to have seen PSR-1 go further, and address method naming in more detail (in particular, that method names should start with a verb), and also address getters/setters and protected vs private.
  • I’ve no personal interest in PSR-2, and am philosophically against “layout” coding standards like this.

… so I wasn’t sure what to expect when I decided to add PSR-3 support to a private framework I use to build test tools at DataSift.

What Is PSR-3?

PSR-3 is a proposed standard (voting has finished, it should appear as an accepted standard when the PSR folks recover from too much Christmas turkey) describing a common logging interface for PHP frameworks.

It’s based on a small subsection of RFC 5424, which describes the Syslog standard, which is a very sensible choice. Sysadmins think in terms of Syslog levels, and they utterly hate dealing with loggers that don’t map cleanly onto Syslog.

What Does The Interface Look Like?

To support PSR-3, you’re required to implement the following methods:

  • emergency($message, $context = array())
  • alert($message, $context = array())
  • critical($message, $context = array())
  • error($message, $context = array())
  • warning($message, $context = array())
  • notice($message, $context = array())
  • info($message, $context = array())
  • debug($message, $context = array())
  • log($logLevel, $message, $context = array())

You can see the proposed interface in full here, including the constants for $logLevel.

The $context is a list of named parameters to substitute into the $message. The special parameter ‘exception’ is reserved for an exception that needs to be added to the logs.

A Critique of PSR-3

PSR-3 is built on a good idea, but there’s three areas where I think PSR-3 could have been better:

  • the method names in the LoggerInterface
  • the handling of the exception parameter
  • the LogLevel constants

I’d have also liked to have seen trace level logging supported, although I can understand why most PHP developers won’t be aware of that practice.

Better Method Names

It’s perhaps a small thing, but I’m a big fan of making code more readable by having all method names start with a verb. I find that it makes code more self-descriptive, and that it’s much easier for casual contributors to grok.

So, instead of this:

  • $logger->emergency(“Captain, she canna take no more”);

we could instead have had:

  • $logger->logEmergency(“Captain, she canna take no more”);

Like I say, a small thing, but in my experience it’s improving all of the small things that leads to big successes, especially in larger code bases.

Handling The Exception Parameter Properly

To paraphrase, the PSR-3 standard says this about the $context parameter: “here’s a list of key/value parameters, but one is special”. That “but” is a code smell!

Not being able to treat all of the key/value parameters equally (slightly) increases the complexity of handling $context, increases the performance cost of logging, and forces the Logger implementation to do things that PHP could handle for us.

A better solution would be to move the exception out of the $context and make it a separate parameter like this:

  • logEmergency($message, $context = array(), Exception $cause = null)

This would allow PHP to make sure that only a genuine Exception was passed into the log method, and would allow the implementation to treat all of the key/value pairs in $context equally. This is a cleaner interface to implement.

Log-Level Constants

RFC 5424 defines the log levels as an ordered set of integers. This is deliberate, as it makes it trivial to say “only log warnings and above”. Unfortunately, because it was difficult to crowbar this into Monolog, the decision was taken to go with strings for the log-level constants. This regrettably increases the complexity of all other loggers.

If you look at pull-request to add PSR-3 to Monolog, you’ll notice that Monolog is explicitly relying on the value of the PSR-3 constants to map them directly onto Monolog class constants:

375	+    public function log($level, $message, array $context = array())
376	+    {
377	+        if (is_string($level) && defined(__CLASS__.'::'.strtoupper($level))) {
378	+            $level = constant(__CLASS__.'::'.strtoupper($level));
379	+        }
380	+
381	+        return $this->addRecord($level, $message, $context);
382	+    }

This is done because (ironically) Monolog already uses numerical log levels internally, with the debug level having a value of 100, and the emergency level having the value of 600. There was obviously the risk of Monolog log level constants being passed in instead of the PSR-3 constants, where it would have been impossible to tell them apart if they were both numeric. I’m sure other existing loggers probably face similar issues.

It’s a tricky issue, but on balance I think the wrong decision was made here for the wrong reason, and the community would have been better served longer-term if PSR-3 had supported the RFC 5424 values for the log level constants.

Final Thoughts

PSR-3 isn’t objectionable … it’s just that it could have been a bit better than it is.

I’ve added both PSR-3 support and the revised methods from this blog post to my internal LogLib. PSR-3 will allow me to inject LogLib into third-party components that support it. My own code will be using the revised methods I’ve proposed here, for the reasons mentioned above.

Comments Off on Personal Thoughts On The PSR-3 Log Proposal

Aim Higher!

Posted by Stuart Herbert on July 26th, 2012 in Opinion, PHP In Business.

At the start of the month, I was on a panel at Unified Diff (which, if you’re in the South Wales area, is well worth your time going to every month), and the last question we had is well worth expanding into a blog post. We were asked what each of us would do with a failing developer, and everyone was taken aback by my unequivocal answer: I’d fire them. After some back and forth between us (which carried on over a pint afterwards), my fellow panelists concluded that I seemed to be able to afford higher standards than they could in their organisations.

And that comment really struck a chord with me.

Fire Failing Developers

So why would I fire the failing developer? By keeping that person on you’re damaging the morale of the rest of the team, and you could end up losing good people and being stuck with the one you should have fired in the first place. (Guess who learned this one the hard way!) You’re also wasting your firm’s money on the person, you’re probably damaging your product, and if the person has any direct contact with your customers, you’re probably damaging your firm’s reputation there too.

Can you turn a failing developer into a star developer? Perhaps, and you should definitely try to do so. In fact, that’s part of your job – to spend every single day trying to turn every developer you manage into a star in their own right. Never wait for someone to start to fail. If you’re doing your job right, then when someone reaches the point where they’ve become a failing developer, you’ve already done all you can about it.

I’ve had to do it a few times over the years, and it feels bloody horrible every time. It’s not a nice thing to have to do, whether it’s an employee or a supplier. I always want to see the best in someone, and I always want them to have the success they deserve. But it’s part of the job, and you do no-one any favours by not facing up to it if it has to be done.

Why Do You Aim So Low?

What about higher standards? How come I seem to be able to afford them when others feel they cannot?

When I was a kid, I sat a lot of exams throughout my school years, but I was never remotely interested in how well I’d done versus everyone else. What I cared about was measuring myself against what was possible. How high could I consistently score? What was the next level up of test that I could sit? What could I learn from other sources? How could I apply it, play with it, really get inside it to start to actually understand it a bit? Where did the hard work need to be put it to take it further still? How could I have fun with it?

I’ve applied this approach to everything I do, whether it’s software engineering, writing, speaking, music, photography, or my martial arts. And I have found it to be liberating. My constraints are my slow-witted mind, my somewhat broken body, and the march of time … and I am in competition not with you, and not with failure, but only myself.

In a world of frankly very low standards, if all you do is measure yourself against the people around you, then it really doesn’t take much to seem like you’re doing pretty well. There are a lot of advantages to being ahead, it’s true, and evolution does favour the lazy … but you’ll never amount to anything much, and you’ll never achieve anything worth a damn if you don’t lift your gaze, look out to the stars, and see what can really be done.

This world is full of people with amazing potential, who never realise that potential. They’re just a waste of space. You can be better tomorrow than you are today. Aim high. You can do it. Everyone can do it. You just have to choose.

We don’t have a lot of time to achieve things in life, and as you get older, you become more and more aware of just how quickly the days are passing. Every day you spend just trying to get through the day … you can’t get that day back. It’s gone forever. And you never know when fate is going to cut your days suddenly short. Make the most of them. Achieve something worth while, and aim high when you do.


Wow. Last week’s opinion piece about switching from Netbeans to Sublime Text 2 has been the most popular blog post I’ve written for quite a while.

As the interest seems to be there, I thought it would be a great idea to follow up with a post taking you step by step through how I’ve set up Sublime Text 2 for PHP development, and showing you some of the useful features that you get out of the box with Sublime Text 2.

You’ll find the details below, and as a bit of an experiment, I’ve also put the details together in a series of YouTube videos for those folks who’d prefer to see ST2 in action. The video directly below is the first in the playlist, and I’ve also put the video for each feature separately further down. If you like the videos, please do click the ‘Like’ button on YouTube so that I know :)

Tip: If you can’t see any YouTube videos on this page, you might need to switch off your browser’s AdBlock plugin and then reload the page.

Install Package Control, Soda, And A Syntax Highlighting Scheme

Out of the box, Sublime Text 2 is a very good text editor. It’s so good, in fact, that I’ve seen people use it in its vanilla form perfectly happily for days and weeks before realising that it can be enhanced with third-party plugins!

The first plugin I recommend installing is Will Bond’s Package Control (installation instructions). Package Control is a plugin that automates the job of installing and upgrading plugins. After you’ve installed it, restart ST2, and then you’ll find a new “Package Control” menu option at the bottom of the “Preferences” menu.

There are over 200 community plugins currently available for ST2. You’ll find them by going into Package Control and selecting the ‘Discover Packages’ option. This takes you to the community packages webpage, where you can browse or search through the available packages. It’s worth going back and checking this page from time to time, as new packages are being added on a regular basis.

The next thing I normally do is reskin ST2. This is entirely a personal preference! Using Package Control, install the ‘Soda’ Theme plugin; this downloads the plugin, but does not activate it. Then, open up the ‘Settings – User’ preferences file (this is a JSON file), and add the following to tell ST2 to use the new theme:

"theme": "Soda Dark.sublime-theme",

You’ll notice a change straight away, but will probably need to restart ST2 for it to pick up all of the new theme properly.

Finally, I setup syntax highlighting to suit. ST2 ships with a number of these, and you can (if you wish) feed it any colour scheme originally created for TextMate. I prefer to use the ‘Phix Color Scheme’, which is available through Package Control.

Editing User Preferences

In ST2, nearly all of the configuration is done by creating and editing config files. There are no user interfaces to click through, just JSON files to edit by hand. There are a few of these files, and the basic idea is that there’s nearly always a ‘default’ config file (which contains the defaults that ST2 or its plugins ship with), and ‘user’ override files.

If you go into the Preferences menu, you’ll see a ‘Settings – Default’ option. This opens the default settings file that ST2 ships with. It’s very well documented, and well worth a browse through to see if there’s anything in there that you’d like to tweak. Don’t make changes to this file; instead, open the ‘Settings – User’ option on the Preferences menu, and put your changes in there. That way, your preferences will be preserved between ST2 upgrades.

Finding Classes With The Goto Anything Pane

There are two ways you can open files in ST2. One way is to navigate through your list of folders in the Project pane on the left hand side of the screen, clicking around with the mouse and drilling down to find the file that you’re looking for. It works … but there’s a faster alternative.

Hitting CTRL+P (CMD+P on the Mac) opens up the Goto Anything pane. Here, you can type in the name of the file that you’re looking for, and in real time, you’ll see a list of matches appear. The searching supports fuzzy matching; you can type in partial search strings, and ST2 will use them to filter out. This is a godsend for working with projects that include vendor folders (which you might not want to search inside), and any Subversion checkouts that include trunk, branches and tags.

Jump To A Line Using The Goto Anything Pane

Press CTRL+G (CMD+G on the Mac), and this brings up the Goto Anything pane, ready for you to type in a line number. As you type, ST2 goes to the line number starting to form in the input box. You can also do exactly the same by pressing CTRL+P and typing a colon at the start of the search. (CTRL+G simply opens the Goto Anything pane and puts the colon there for you as a shortcut).

You can also combine this with the file search. Hit CTRL+P and start searching for a file. Then, at the end of your search, add a colon, and then the line number that you’re looking for. This will take you to that line number in that file – all from the keyboard.

Goto A Defined Symbol Using The Goto Anything Pane

Press CTRL+R (CMD+R on the Mac), and this brings up the Goto Anything pane, ready for you to type in the name of a function or method. As you type, ST2 narrows down the list of matching functions, methods and classes in your file. You can do the same by pressing CTRL+P and typing an @ symbol at the start of the search.

You can combine this with the file search. Hit CTRL+P and start searching for a file. Then, at the end of your search term, add an @ sign, and then the name of the function or method that you’re looking for. This will take you to that function or method in that file.

Coding Quicker With The Additional PHP Snippets

The Additional PHP Snippets plugin [disclaimer: I’m the author of this plugin] provides a few simple text snippets to speed up everyday chores such as creating getters and setters, and add license text to the top of the file. It is available via Package Control.

Pull requests (or requests for features) are most welcome.

To use it, inside your PHP code, simply type ‘php-‘, and ST2 will show you a list of all of the matching snippets. Select the snippet you want, hit TAB, and hey presto – the snippet is dropped into your code, ready for you to adapt as required.

Creating Doc Blocks Using DocBlockr

The DocBlockr plugin makes it very quick and easy to create doc blocks for your classes, attributes, and methods. It is available via Package Control.

To use it, open a new doc block as normal by typing ‘/**’ and then pressing ENTER. The plugin will create a template doc block for you to fill out to suit.

Real-Time Syntax Checking Using SublimeLinter

Real-time syntax checking is something you take for granted with an IDE, and it’s available in ST2 in 2 main flavours. I use the SublimeLinter plugin myself, and have had no trouble with it at all, but I know that some folks have had to use the sublime-lint plugin instead. Both are available via Package Control.

Once installed, your code is checked in real time for syntax errors. Lines that contain syntax errors are highlighted, and in the status bar at the bottom of the screen, you’ll see an explanation of what the error is.

Sometimes, the syntax error will appear to be on the wrong line – on the line below where the real problem is. SublimeLinter uses the ‘php -l’ command behind the screens – PHP’s built-in linter, and is simply reporting back exactly what the PHP runtime thinks is wrong. This might puzzle you at first if you’re used to IDEs that have their own lint algorithm built in.

Consulting The PHP Manual Using Goto Documentation

The PHP Manual is, imho, PHP’s true killer feature: all that detailed documentation, and it’s all freely available on the web (no need to go away and buy books on the language). Like many PHP developers, I’ve always got the PHP Manual open when I’m working.

The Goto Documentation plugin allows me to look up any PHP function from inside ST2. The plugin is available via Package Control, and once installed, you need to bind it to a key before you can use it. This is done by opening the ‘Key Bindings – User’ option on ST2’s Preferences menu, and adding a line like the following:

{ "keys": ["f1"], "command": "goto_documentation" }

Save the file, and you’re ready to go.

To use it, just put your text cursor on the PHP function that you want to look up, and hit your chosen key combination. Goto Documentation will switch to your browser, and search the PHP Manual for the function you’ve selected.

Handling Trailing Whitespace Using The TrailingSpaces Plugin

I know it’s a small thing, but trailing whitespace annoys the crap out of me, and I’ve always been deeply frustrated with how Netbeans never reliably stripped this from files that I created or worked on. Thankfully this isn’t a problem with ST2, and you can add the TrailingSpaces plugin to strip files in between saving them.

Testing Using PHPUnit

The PHPUnit plugin [disclaimer: I am the plugin’s author] allows you to run your unit tests right from inside ST2. You can run the tests for just the file you’ve got open, or you can run all of your project’s unit tests in one go. You can also switch back and forwards between your PHP code and your unit test files, and you can quickly open your project’s phpunit.xml file.

To use the plugin, your project needs to have either a phpunit.xml file, or a phpunit.xml.dist file. This is a simple config file that tells PHPUnit where your tests are, which folders to include / ignore for code coverage purposes, and what reports / logs PHPUnit should create once the testing is done. If you’re using something like Phix, you get all of this for free, and I believe that Symfony’s standard app skeleton also includes a phpunit.xml file too.

The plugin navigates around your project, switching from file to file, using the following algorithm:

  1. It takes the full name of your PHP class, including the namespace, and uses the PSR0 autoloader algorithm to try and find the same class with ‘Test’ appended on the end. If that doesn’t work, it strips off the namespace and tries again.
  2. To find the phpunit.xml file, the plugin finds the test code first, and then searches each folder upwards for phpunit.xml or phpunit.xml.dist. If that doesn’t work, it looks in a number of pre-determined locations (defined in the plugin’s settings file), and then as a last resort it searches your whole project downwards starting from the top folder.

When you run your tests, the full output from PHPUnit appears in a panel at the bottom of ST2’s window – and that includes information on the full command executed, and which folder it was executed from. To close the panel, just hit ESC.

Alignment Plugin

This is a very simple plugin; it allows you to select some lines of code, and have all of the equals signs line up under each other. I find that this can make code (and especially array definitions) much clearer to read, but I know that it isn’t for everyone :)

Software Archaeology Using CTags

One of the ways that IDEs add a lot of value is that they truly understand the code you’re working on, and that allows them to offer features like ‘goto source definition’ et al. There’s a way you can do this in ST2, by installing the CTags plugin.

Once you’ve installed the CTags plugin, before you can use it, you need to go to the plugin’s website and follow the instructions there to get a suitable ‘ctags’ command line program installed. The plugin is a wrapper around this command’s functionality, and cannot work without it.

Then, the next step is to build a tags file. This is an index of all of your code, that the plugin can use to look up classes, functions and methods so that you can quickly jump to their definition from anywhere in your project. This is done by hitting CTRL+T and then CTRL+R, and then waiting for the ‘finished building’ message to appear in the status bar.

After that, you can navigate around your code by hitting CTRL+T and then CTRL+T again. This works particularly well for exploring code you haven’t seen before, something that I demo in the video below.

One last word of advice. CTags understands the syntax of your code, but not the strategy. It doesn’t understand the difference between trunk/ and branches/ folders, for example, or vendor/ folders. If there’s code in there, CTags by default will index it. This might be what you want, but if you find that it’s picking up duplicates that you’re not interested in, you’ll need to create a CTags.sublime-settings file in your User/ package folder to override the ctags_command setting and add in some exclusions.

What Else?

There’s one notable exception that I haven’t covered here, and that’s SublimeCodeIntel. This is a plugin that aims to bring Komodo’s autocompletion over to ST2. It’s a great idea, but my own experience with the plugin isn’t good. I’ve seen it installed on two different computers running the same OS and version of ST2, and it work fine on one and not work at all on the other. I’ve seen it stop working after a new version of the plugin was released. I’ve learned to live without it. But do go try it out, because if it works for you, you might really like it.

Are there any other ST2 plugins that you use on a daily basis? Mention them in the comments below, and I’ll check them out :)


I’ve recently switched from using Netbeans as my PHP dev tool of choice to Sublime Text 2. Features-wise, I think Netbeans is great. During the years I used it, I never felt that there was a feature I needed that was missing at the time. But, like all the current crop of Java-based desktop IDEs, it’s so damn ugly [1] and slow [2] that I’ve had enough. I program because it’s something that I love doing, and anything that gets in the way of that … I’ve no time for any more. So when a work colleague introduced me to Sublime Text 2, I was in the mood to give it a go, and 3 months on, I haven’t opened Netbeans once.

I’ll be the first to say that Sublime Text 2 isn’t for everyone.

  • It’s a beta product, which means there are some rough edges (mostly in the plugin API I feel), but it’s more than stable enough for production use. It has crashed a couple of times, which might put some people off, but I don’t recall losing any work as a result. File management in the project pane still needs work. The regular dev builds occasionally break things.
  • It isn’t a full-blown IDE; it’s more like the spiritual successor to TextMate, an editor that I never personally cared for. In particular, it doesn’t support interactive debuggers, which means no Xdebug support, and there’s currently no obvious way for a plugin to add that functionality in [3].
  • Auto-completion isn’t anything like what you’re used to. The built-in auto-completion is based on a mix of static knowledge of languages and fuzzy matching against what you’ve recently typed. There’s no obvious intelligence about the code you’re working on, nor the parameters for any method or function. These are two things that many people will deeply miss. [4]
  • It isn’t free, but you can evaluate it for free with no time limit. If you decide to buy, it’s substantially cheaper than both PhpStorm and Zend Studio, and there’s no annual subscription element to the licensing. You’re buying a license to support and encourage an independent developer, and to show your appreciation for a very nice piece of software.
  • It’s a closed-source product. You can’t fix it yourself if it breaks, and no-one can pick up the reigns if it gets abandoned. There seems to be just one guy behind it, and if anything happened to him, that’d probably be the end of the product. That said, most of the alternatives are also closed-source too.

Given all of that, why have I switched?

  1. Sublime Text 2 is very very fast. Sublime Text 2 itself opens instantly. Files open instantly (provided they’re not 100 megabyte test data files). In fact, everything happens instantly – even inside a virtual machine running on a 3 year old laptop. There are no pauses for anything to be indexed, and I’ve never seen CPU usage spike – important for us untethered users and our suffering laptop batteries [5]. And if a plugin slows things down at all, Sublime Text 2 tells you which one is the culprit so that you can go and disable it. I’d compare the importance of the speed difference to switching from a hard disk to an SSD. You don’t realise how much you’re waiting for your slow Java-based IDE until you use something that’s properly fast.
  2. It renders fonts properly – Droid Sans Mono and Ubuntu Mono in particular both look gorgeous – and even after a long day of use, my eyes don’t feel like they’ve been scratched on the inside by sharpened kitty claws all day long [6]. True story: one of my colleagues came over to ask what I was using, because he thought it looked so nice from a distance. When was the last time anyone ever thought that about a desktop Java app?
  3. All of the searching is based on an extremely powerful fuzzy matching approach. Netbeans supports regexes, which can be very handy, but most of the time when I’m looking for something, a regex is overkill but a simple string search isn’t powerful enough. If I’ve got both a class called ‘IpcProcess’ and ‘IpcProcessID’, in Sublime Text 2 I can find the ‘IpcProcessID’ class by searching for ‘ipi'; I just have to type the shortest set of characters that uniquely matches what I’m looking for. It’s much quicker than writing (or running) a regex, and soon becomes second nature.
  4. There’s a “goto anything” search panel which is lightning quick. Combined with the fuzzy matching approach, I find this a godsend for working on multiple large code bases, where there may be different classes with the same base filename, or duplicate installs of a class in vendor folders, or where I’ve got both trunk and branches checked out for the same project. It’s a killer feature, and one that has changed my workflow for the better, especially combined with my next reason. The panel’s also like using Google Instant – you get results as you type, giving you the instant feedback you need to refine your fuzzy search. (There is also a “goto symbol” search panel, and a “command palette” which allows you to search through the available editor commands to execute).
  5. Everything can be done from the keyboard. Everything can be done from the mouse too, but I found that doing everything from the keyboard is both faster and doesn’t break the flow of what I’m working on. This is something I didn’t appreciate until after I’d switched, but it’s a fantastic help to me when I’ve got another developer sat next to me and we’re looking at (or for) something together. Together with the fuzzy matching, it’s like doing software archaeology with a JCB digger instead of a trowel.
  6. It does a great job of auto-detecting whether a file uses spaces or tabs for indentation, and how big the tab stop is. There are days when it seems like no two files I open are consistent in how the code is indented, and it’s rare for anyone to have tagged on a modeline to give any hints. With Netbeans, which has a rigid config-based approach to indentation, I end up playing code-formatting table tennis with the original author of the file, as we always seem to have different indentation settings. Sublime Text 2 works out what the existing indentation approach is, and just auto-configures itself to match. It’s a great time saver [7].
  7. It strips trailing spaces from the ends of lines when I save my files. This has been broken in Netbeans for years! It’s a small thing, I know, but it really annoys the crap out of me that Netbeans doesn’t get this right. As a bonus, in Sublime Text 2 trailing spaces actually get their own setting in color schemes, so you can see exactly where they are. In Netbeans, they’re bloody invisible :(
  8. There’s a healthy ecosystem of plugins for it – over 200 plugins and counting – thanks to Will Bond’s Package Control package manager. Will is doing a great job of making sure that each plugin is tightly focused on sorting one problem only, to keep Sublime Text 2 as flexible and adaptable as possible – something to keep in mind if you start writing plugins yourself.
  9. Creating new plugins is very easy. It took me just one evening to add and release the initial PHPUnit plugin, and that included the time it took to learn both Python and the plugin API from scratch. To make an update to your plugin, simply push your changes to your master branch on GitHub. It’s as close to frictionless as you can get.
  10. I can own the tool, and set it up to suit my approach to programming. Because extending the editor is so effortless, I can automate anything that I want, to suit exactly how I want it done. I can create snippets, intelligent macros, and full-blown plugins to suit, and I can make them as and when some new need occurs – even one-off tasks. In this, it reminds me most of JED, which was my text editor of choice back in the 90’s for exactly the same reason. It’s the same reason folks love Vim. (Btw, Sublime Text 2 has a Vim mode. I haven’t tried it, so I can’t vouch for whether it’s good enough to tempt Vim users over or not).

Like Netbeans, Sublime Text 2 works on OS X, Linux and Windows [8], so I can use it everywhere I used to use Netbeans. I reckon it occupies a sweet spot that makes it very well suited to scripting languages and C/C++ development, albeit minus support for interactive debuggers.

At work, some of us have taken to it, and some of us haven’t. I’m happy to recommend it to anyone who’s looking for a change. You can take advantage of the open-ended free evaluation period, and see if it suits you or not. It’s working for me so far, and I probably spend more time using it than any other app on any of my computers.

If you do like Sublime Text 2, I’d love for you to leave a comment below with your own reasons why.


  1. Dear Java, the 1990’s called and asked for their crappy non-aliased font renderer back. I think Windows 3.11 is missing it terribly.
  2. There was a similar parallel around 20 years. At the time, Emacs was by far the most fully-featured editor, but everyone I know chose vi because of how slow and bloaty Emacs was at the time. It was so bad, we used to say that Emacs stood for “Eight megs and constantly swapping” (this was back in the days of 640K of RAM).
  3. The lack of debugger support is, for me, the one feature that I miss every single day.
  4. There is a plugin that tries to bring Komodo’s auto-completion to Sublime Text 2, but it stopped working for me before Christmas sadly.
  5. It’s like when you switch from Firefox to Chrome for the first time … your laptop just gives a sigh of relief, and you don’t have to worry quite so much about how far away you are from the next convenient wall socket to recharge from. I can easily imagine running this on a netbook, or a laptop with very aggressive CPU throttling in place – both places where a Java-based IDE would struggle.
  6. I’m highly visual, and find it really tiring to spend 10-12 hours a day in front of poorly-rendered fonts.
  7. Now, if only everyone just did the right thing in the first place and used spaces instead of tab characters, we wouldn’t need functionality like this … :)
  8. The keybindings are different from one platform to another, and because Python isn’t a platform-agnostic language, some plugins may not work properly on Windows at first. But most plugin authors are happy to accept pull requests with portability fixes.

Ideas Of March

Posted by Stuart Herbert on March 15th, 2011 in Community, Opinion.

Chris has made a timely call for everyone (especially the Twitterati) to start blogging about PHP once more. Much of our community’s interaction has moved to Twitter and conferences, and we’re simply not leaving enough longform content out there any more.

There’s a key reason why I blog less about PHP these days, though, and it has nothing to do with Twitter. Our wider community simply doesn’t read blogs any more (if they ever did). They’ve already moved on to StackOverflow, and other similar places.

This is just my experience, and we can all put it to the test:

  • Go along to your next PHP User Group, and ask for a quick show of hands for how many people there are subscribers to Planet PHP, where we’ve aggregated blogs about PHP for many years now.
  • Then, the next time you’re at a large conference, ask everyone you meet the same question.

Over the years, I’ve found that our wider community doesn’t have the time to keep up with the blogs; but when they get stuck and the excellent PHP Manual can’t help them, they hit Google (and latterly StackOverflow) for quick answers. I’m always stunned by how few people have ever heard of Planet PHP.

This is also reflected in pageview and feed analytic stats, where nearly all the traffic comes from search engine queries. Planet PHP sadly ranks at #10 in my stats; I get more views from an ajax development site, even though I’m assuredly a backend engineer.

These are just my experiences. I would welcome you sharing yours!

What does this all mean to me?

  • We all need to do much more to promote Planet PHP (offline!) as the hub for proactive developers to stay up to date with what’s going on in the world of PHP. Why Planet PHP? My apologies to those who put a lot of fantastic work into other community sites, but they don’t seem to generate any measurable traffic at all.
  • Our community values hands-on, targeted articles that describe and solve specific problems that they encounter. They go looking for such content every day, and when that fails, they resort to StackOverflow et al.
  • We need to encourage our fellow developers to make time to develop their own skills, so that they don’t have to be hitting Google to react to an avoidable problem in the first place. Encourage your friends and colleagues to create and share reading lists, or to give a talk or demonstration at their local PHP user group. Get involved with community education projects like PHP Fundamentals, so that we can create a self-educating profession.

And, above all (irony intended …) use Twitter for the opinion pieces, where the world can forget them after 4 days :)


By now, you might have heard the details of HipHop, Facebook’s PHP-to-C++ convertor that was announced yesterday. Like most of you, I’m eagerly awaiting the release of the code so that I can play with it and learn in detail what it can do and what it can’t. For now, Marco’s post seems to have the most technical information in it so far.

I’m with Sebastian on this one. Whether or not you think Facebook’s HipHop is relevant to you, I think they deserve credit for having shared their particular solution with the wider community. (They’ll get extra credit when they actually release some code :) ) After all, they’ve built on top of open-source in the first place; giving something back to the community is part and parcel of being a good member of the community.

How many of you earn your living from open-source, but have never contributed anything back?

But that isn’t really what I want to blog about today.

I’ve been following the chat on Twitter about HipHop, and I think all the nay sayers have been overlooking an important point. HipHop has the potential to reduce the amount of power consumed in running a website. And surely that can only be a good thing for all of us?

If you don’t run your own servers in a data centre (for example you use a virtual server, or host on a shared hosting solution), then perhaps you might not be aware that the power required by each server in a rack is often a major factor in the overall cost of running the servers. Whether or not you believe in climate change, energy prices are on the rise. Whether or not you believe in peak oil, oil and natural gas supply issues are forecast to push energy prices up further. Taking steps to get more work done per unit of power consumed has been the focus of hardware manufacturers for several years now. Isn’t it time it also was the focus of the software community too?

CPU usage is only one aspect of the total power consumed by a server in a rack, but in my experience people tend to add more servers to their solution primarily because they need more CPUs running their web servers to handle more traffic. A reduction in the number of CPUs required will translate into a reduction of the number of servers required … which means a reduction in the amount of energy being consumed.

How can that not be a good thing, if it can be achieved?

I know the answer will be that PHP apps are not CPU-bound, that they spend much of their time waiting for results from the database. That might be true if you’re measuring a PHP app from the point of view of elapsed time, but what if you’re measuring the PHP app in terms of CPU cycles consumed? Every single PHP script has to run on a CPU, and has to get to the point where it’s sat waiting for the database. If HipHop means that each PHP script uses less CPU to get to the same point, that has to be a step in the right direction.

Until we can play with HipHop ourselves, it’s impossible to say whether it saves enough CPU cycles to allow us to use less CPUs and therefore less servers. Remember, you’ve still got the overhead of your operating system and web server to factor into the equation. And then there’s the energy cost of compiling your code in the first place during development; for seldom-visited websites, HipHop may increase overall energy requirements.

But it sure is nice to hope, isn’t it?

Be the first to leave a comment »

Looking At PHP On Windows Adoption

Posted by Stuart Herbert on September 11th, 2009 in Opinion.

On Zend’s DevZone, Remi Woler recently talked about his experiences as a judge for the WinPHP contest organised through the Dutch PHP User Group and the Dutch PHP Conference. One of his closing remarks really stood out for me, where he was expressing his surprise at how few people participated: “I refuse to believe there are only a couple of dozen PHP developers in Europe.”

It’s an odd statement … the world and his dog knows that PHP is immensely popular over here in Europe. Perhaps Remi completely overlooked the Windows factor here?

  1. I’ve been running a series of polls looking to learn more about the wider PHP community. One of the things that comes out of those polls is that 15% of developers use Windows as a platform, but only 3% are using Windows for their production platform.
  2. At this year’s PHP UK Conference in London, Microsoft’s Hank Jansen (who heads up their open-source efforts) spoke in the main room. I wasn’t able to attend personally, but by all accounts his talk was not well-attended. Not only aren’t people using Windows, but the curiosity doesn’t seem to be there either.
  3. Most hosting services (and practically all shared hosting services) are Linux based. If you want to host your site on Windows Server, there are plenty of firms offering this as an option, but many of these services are beyond the budget of many PHP projects.

My personal experience over the years is that many developers work in PHP on Windows because they’re working on laptops … and Linux on laptops continues to be a very hit-and-miss experience sadly. (They should all buy Macs instead 😉 ) About half of the larger corporations I’ve worked with in the UK prefer Windows Server because Linux skills are rare in their organisation, but these corporations were also reluctant to use PHP-based solutions, still wrongly seeing PHP as a hobbyist language compared to .NET or Java.

Be the first to leave a comment »

Poll: Have you adopted PHP 5.3 yet?

Posted by Stuart Herbert on September 1st, 2009 in Opinion, Toolbox.

Earlier in the year, before PHP 5.3 was released, I asked the community a series of questions about their attitudes towards moving to PHP 5.3, and had a fantastic response. I’m going to turn all of those answers into a new conference talk that I’m working on.

Now that PHP 5.3 has been around for a few months and we’ve started seeing plenty of blog posts covering all the new features in PHP 5.3, I’m wondering whether or not you have actually moved to PHP 5.3 yet. I’m especially curious to see how this compares to what people said they’d do before it came out :)

Please vote on twtpoll to let me know if you have moved to PHP 5.3, and if not, what’s still stopping you. Many thanks in advance!

Be the first to leave a comment »

I’ve been running a series of polls as research for a new conference talk that I’m currently putting together. The first two polls have had over 1,200 votes between them so far, which is a fantastic response! Now I just need your help with one final poll :)

Please vote on twtpoll to let me know where will you get your PHP 5.3 from? Many thanks in advance!

Be the first to leave a comment »

A huge thank you to everyone who voted in my last poll about when you’ll adopt PHP 5.3, and everyone who has provided feedback on the problems caused by the way individual distros package PHP. I’ve had much more feedback than I could have hoped for! This is all useful research for a new conference talk that I’m preparing.

My next question for the PHP community is about where you’ll use PHP 5.3. I’m wondering: which server platforms you’ll choose to put PHP 5.3 on when the time comes? This new poll is multi-choice, allowing you to vote for all of the operating systems that you choose.

Many thanks in advance for your answers :)

Be the first to leave a comment »
Page 1 of 212

This Month

October 2015
« Aug