Standard Code Formatting with EditorConfig

EditorConfig is a very simple configuration file that can be used in any code base to define formatting expectations like spaces or tabs, size of tab, file ending newlines, etc. Installation First you will need the editorconfig binary. On a Mac with Homebrew, this is as simple as: brew install…

Better Commits with Static Review

One of the best changes that I have recently ever made to my workflow has been reading Chris Beams' excellent How to Write a Git Commit Message. If you haven't read it, you should go do it right now and come back once you are done. The Problem You're programming…

The Binary Classification of Objects

After working on immutable data structures and dependency injection with Auryn I often find myself questioning class constructor style when doing code reviews. Recently I was reviewing a pull request that had this signature in it: public function __construct( RequestInterface $request, DateTime $now, $key, $ttl, $algorithm = 'HS256' ) { ... } A Funny Smell…

Configuration in Spark

Building on my last post about dependency injection I thought it would useful to talk configuring Auryn within the context of Spark. Basic Configuration The default configuration of Spark is in web/index.php. If you were to add configuration for PDO the easiest thing to do would be: $injector…

Dependency Injection with Auryn

Dependency Inversion is Hard One of the hardest things to do properly when following SOLID principles is Dependency Inversion. I struggled to understand and implement this concept for years. Often I wondered if it was really worth the trouble to write all of that extra configuration just to simplify testing.…

A simple REST application with Spark

What is Spark? Spark is a PSR-7 micro-framework that implements the Action Domain Responder pattern created by @pmjones. ADR can be summarized as a "clean code" version of MVC, with specific differences that help us achieve SOLID principles. Install Spark This assumes that you already have Composer installed. $ composer create-project…