Friday, 22 February 2013

PHP namespace conventions

With the advent of namespaces in PHP, code is thankfully getting much less complicated by reducing the somewhat messy class naming (though namespacing does affect more than just classes).

As a developer, and stepping into the world of PHP namespacing for the first time, I began to start asking myself about standards and conventions. Many of PHP's features can be interpreted in a number of different ways and namespacing is no different, so a standard would be really helpful, especially in larger projects.

Luckily, a PHP Standards Working Group have put forward a proposal that makes geat sense as a standard to work to. This standard also allows for easily autoloader support which I was also after.

Here's the basic rules:
  • A fully-qualified namespace and class must have the following structure:
    • \<Vendor Name>\(<Namespace>\)*<Class Name>
  • Each namespace must have a top-level namespace ("Vendor Name").
  • Each namespace can have as many sub-namespaces as it wishes.
  • Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system.
  • Each _ character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The _ character has no special meaning in the namespace.
  • The fully-qualified namespace and class is suffixed with .php when loading from the file system.
  • Alphabetic characters in vendor names, namespaces, and class names may be of any combination of lower case and upper case.

More information on the proposed format know as PSR-0 can be found here:

Tuesday, 19 February 2013

Is hardware becoming throwaway to the extreme?

I've used Apple hardware since the mid 1990's and have seen numerous different itterations including 3 major processor changes. As a result I've become quite accustomed to managing desktop Mac's when they inevitably come to the end of their life.

I would also say that in my experience, most people who regularly use a desktop machine for both work and leisure have a reasonably sound knowledge of how to repair or at the least diagnose things when they go wrong. This has always been a helpful skill to have in my opinion. Over the past few years however, hardware has become significantly closed to the point of rendering DIY maintainance almost impossible.

Tuesday, 12 February 2013

Instant Placeholder for Web Development

One thing that i've found quite useful recently is a simple javascript api that creates placeholders. These are extremely useful when constructing websites to map out a layout without having to add additional CSS or sourcing test images.

Holder.js is hosted on github

Usage is as simple as:
<img src="holder.js/300x200">

Monday, 4 February 2013

CSS Tips

I've been writing CSS for many, many years now and while there is a fairly basic understanding of the system to many web developers, there are a few things that some may not be familiar with.
For example…