PHP tags – once and for all. Yet again.

For those of us who have been using PHP since the early version 3 days and such, here is a modern day refresher for PHP tags:

If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.

And from the comment on the same page:

Since PHP 5.4 the inline echo <?= ?> short tags are always enabled regardless of the short_open_tag (php.ini) setting.

For me personally, closing PHP tags are a part of muscle memory.  I’ll have to unlearn that, I guess.  And in regards to the inline echo tags, I was under the impression that they are being phased out together with the other short tags (<? … ?>).  Apparently, I was wrong.  They are here to stay.  Which explains why there are in PSR-1, PSR-2, and in CakePHP 3 (which requires PHP 5.4.16 and fully adopts PSR-2) in particular.

1,000 Chrome Experiments

Chrome Experiments is a collection of projects that push the limits of the Google Chrome browser.  They’ve recently reached a 1,000 contributions.  Some look simplistic, some are stunning.  Some are just little toys, yet others have practical application.  Definitely deserves a minute of your time.  Which will probably eat a half an hour before you’ll notice.

Chrome Experiments

For me, the 1,000 is a cool looking thingy, with useful feature of browsing through random projects.  The most interesting is the ISS Photo Viewer.

Puppet : Beginner’s Guide to Modules

I’ve been using Puppet here and there for about a year now.  In the last six month, I went rather heavy, and managed to accumulate quite a bit of modules, configs, hosts, etc.  Refactoring some of the code, and trying out new ideas, I’m reading through the Beginner’s Guide to Modules to help me with the best practices.  A couple of bits from there, I think, are worth quoting:

(Tip: If you describe the function of your module and you find yourself using the word ‘and’, it’s time to split the module at the ‘and’.)

This above is useful to people like me, who got comfortable throwing bits and pieces into modules, but don’t quite know yet where is that thin line for the module separation.  The above tip makes that crystal clear.  So, for example, “my module installs and configures something” no becomes two modules, where one “installs something” and another “configures something”.

It is standard practice for Puppet users to have upwards of 200 modules in their environment.

With this I know that my current setup is rather small and simplistic.  It’s not the numbers I am after, of course.  But, again, it’s difficult to say if I am doing too much of it, or not enough; if the system has been built to scale to the level where I am.  It turns out,  I have a long way to go.  A quick check shows that I’m at 127 modules in my current setup.  And that one is used for configuring pretty much everything – base installs, web / db / dev servers, desktops, etc.

Some of it will get expanded as I am replacing quite a bit of my own modules with third-party ones.  Interestingly enough, I wasn’t comfortable using other people’s code in the beginning and wanted things to be precisely my way (there were some time constraints).  It worked well, for a time.  But not a lot of it can be thrown away and replaced with other people’s code.  More features and less maintenance for the win!