Funemployed Mar 20, 2014

After running Brightbit with Joshua Ogle and Eric Boehs for nearly fours years, it officially came to an end a few weeks ago on February 28, 2014 when we closed the office. It’s a long story, and there is no blog post for it yet, but now is not the...

MacBook Pro Retina 3.5mm TRRS Cable With Audio Input Mar 8, 2014

One of the unexpected surprises that came with upgrading to a new Macbook Pro Retina 15" from an older MacBook Pro was Apple’s inexplicable deletion of the audio input (mic) 3.5mm jack. I use a regularly use a gaming headset with a boom mic that was...

Oklahoma PHP User Group Reboot Mar 3, 2014

Our first Oklahoma PHP User Group meeting in a few years happened on Thursday, February 20th 2014, thanks to the efforts of Jake A. Smith who contacted me about it (as I ran the previous PHPUG a few years ago) and did all the legwork to make it happen...

Using Dokku to Deploy PHP Applications with a "git push" on DigitalOcean Feb 8, 2014

Want a Platform-as-a-Service setup like Heroku on your own $5/month VPS from DigitalOcean? Look no further than Dokku - a set of scripts built on Docker and Heroku’s own buildpacks. After this setup, you’re just one git push away from deploying your...

SkiPHP Conference 2014 Jan 22, 2014

It’s always fun to be a part of a conference’s first year. This year, I was lucky enough to speak at the inaugural SkiPHP Conference in Salt Lake City, UT. Since the conference was very micro-framework friendly, I was able to present my own Bullet...

New Year, New Blog Jan 4, 2014

It’s a whole new year, and I’ve got a whole new blog. This time around, I knew I wanted a static blog generator instead of a WordPress site (they are a little more developer friendly, and there are no security vulnerabilities with static HTML), and...

Valitron: The Simple Validation Library That Doesn't Suck Mar 4, 2013

Valitron is a simple, minimal and elegant stand-alone PHP validation library with NO dependencies. Valitron uses simple, straightforward validation methods with a focus on readable and concise syntax.

Why Another Validation Library?

Valitron was...

Introducing Bullet: The Functional PHP Micro-Framework Dec 20, 2012

Bullet is a new PHP micro-framework with a unique functional approach to URL routing that allows for more flexibility and requires less verbosity than the more typical full route+callback approach found in other micro-frameworks.

The Problem with Independent Scope

The main problem with most micro-frameworks and even full-stack MVC frameworks that leads to code duplication is that the callback or method executed to perform the action and respond to the URL route lives fully within its own scope. This means that you are forced to repeat a lot of setup code across URL route handlers that load the same resource, authorize it, etc.

Some typical micro-framework code might look like this:

<?php
// View single post
$app->get('/posts/:id', function($id) {
    $post = Post::find($id);
    check_user_acl_for($post);
    // ...
});

// Delete post
$app->delete('/posts/:id', function($id) {
    $post = Post::find($id);
    check_user_acl_for($post);
    $post->delete();
    // ...
});

// Edit post
$app->get('/posts/:id/edit', function($id) {
    $post = Post::find($id);
    check_user_acl_for($post);
    // ...
});

You may be able to move the ACL check to a middleware layer or “before” hook if the framework supports it, but there is always a certain amount of duplicate code you will either never be able to get rid of, or have to jump through hoops to get rid of (like adding more abstraction or re-checking the current URL, etc).

The Benefits of Shared Scope

Bullet uses a unique nested callback style that splits the URL by directory separator and only handles a single part of the URL at a time with it’s own callback. At first blush, this approach might seem like more work, but the key to how Bullet works is that nested closures - by definition - can use variables defined in the scope of their parent. This leads to some pretty powerful and profund capabilities that can only be done using the same nested closure style that Bullet uses.

Handling Exceptions in Gearman Tasks (Even Background Ones) Jul 31, 2012

I recently had some issues with Gearman tasks throwing exceptions and killing the whole Gearman daemon. This made it nearly impossible to trace errors back to their origin, because the logged exception stack trace didn’t provide much useful information...

Confoo 2012 Montreal Apr 13, 2012

My second year speaking at Confoo was more fun than my first. This year I met a lot of new people and had a lot of interesting discussions, particularly in the CMS room and at lunch after my Stackbox CMS presentation. The whole philosophy and approach...