The PHP magic method __invoke provides a powerful way to encapsulate functionality while separating state from results and error...
Friday, November 13, 2015
Friday, November 6, 2015
Tuesday, October 27, 2015
PHP array de-duplication trick that'll save you lots of CPU (* YMMV)
Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.
― John Woods
Today, I discovered this curious gem in legacy code:
<?php
// ✂ ...snip... wall of code that creates array $ids
$ids = array_flip($ids);
$ids = array_flip($ids);
// ✂...
Wednesday, October 14, 2015
404
I'm terribly sorry, but I can't find the page you have requested.
Believe me, I looked for it. Really! You can't even imagine the
millions of calculations I had to go thru to look in all the places
my owner could have left what you asked for. But I couldn't find it. It's not there! :-(
No,...
Tuesday, October 13, 2015
On collaboration.
If you want to walk fast, walk alone.
If you want to walk far, walk together.
-- African prover...
Friday, August 28, 2015
Jenkins and Skype: Back Together Again
So, all us developers use Skype. But there's one member of the team who, until today, wasn't on Skype: Jenkins.
Getting Jenkins onto Skype is possible, despite Microsoft killing API access in Skype. In this post, I show you a six step process to configure Jenkins to message you over Skype...
Tuesday, June 2, 2015
Dealing with uncomposable PHP dependencies
For managing dependencies in PHP, you rely on Composer. But how do you manage a dependency that doesn't support composer? Simple: weave it into your repository using braid...
Wednesday, May 27, 2015
Shaking out dependencies in PHPUnit unit tests
Isolation is a unit test ideal. You should, in theory, be able to run them in a random order, or in parallel, with no effect on the results. PHPUnit provides no options to do this, but, fortunately, two neat GNU command line utilities can help...
Thursday, May 21, 2015
How software dies
When software reaches its design apex, the passion to develop it wanes and it begins descending through maintenance hell. What was once state-of-the-art becomes legacy, and once legacy becomes abandonware. Except for those rare software gems that endure for generations...
Tuesday, May 19, 2015
"Writable" is wrong!
Incorrect and inconsistent spelling makes searching harder:
function initDb() {
$datbase = PDO::get();
$datbase->check();}
If I searched my code base for "database", I'd miss this hit. That sucks. Please take the time to correctly spell. (Corollary:...
Thursday, February 19, 2015
App::error, Accept:application/json, and app.debug = false
Application crashed? Client only accepts application/json? Unless your Laravel 4 application is in debug mode, you're out of luck: the client receives text/html...
Thursday, January 15, 2015
Memoization 2.0
You might think "Memoization" is a typo, but it's not. Memoization is a simple technique to improve software performance. Unfortunately, the technique relies upon repetitive boilerplate. In this article, I show you how to use memoization without any boilerplate cod...
Tuesday, January 13, 2015
Laravel Tip: API Quick reference with Liona
If you've never visited the #Laravel IRC channel, today might be the day to stop by. Besides offering authoritative answers to Laravel questions, the channel also offers instant access to all the Laravel API documentation. In this article, I show you the secret command to find all the Laravel API d...
Saturday, January 10, 2015
Pudgy controllers? Try the Route diet!
Nestled between user and controller, the routing layer is a perfect home for common filtering and access-control oriented code. But you have to know your framework's routing capabilities to exploit this location. In this article, I share a users' group presentation on the supple Laravel 4 Route ...
Thursday, January 8, 2015
Zero to PSR-4 in 60 seconds
By and large PSR-0 and PSR-4 are identical. Comparing and contrasting the two doesn't illuminate the crucial, but small, surface area where they differ. Sadly, most documentation takes this compare and contrast approach. In this article, I break with that documentation pattern and rather focus...