Portfolio and Technology Blog
by Kevin Boyd

The Llama Commander

When I'm in an experimental mood, or working on a proof of concept, I like to code in a scrappy way. Anonymous functions allow me to avoid pausing my train of thought to think of a name for something. However, when I'm using the Symfony Console Component to write command-line utilities, it seems that I have to write a class for each command.

No more, I say!

I've created a tiny library called beryllium/llama that lets me set the configuration and execution logic of console commands using anonymous functions, right in the constructor. When I found myself using the technique across several projects, I did what anyone would do - I gave it a silly name and threw it on GitHub and Packagist.

Read more of this post »

October 19, 2015

Tags: coding, dev, development, silex, command-line

Sculpin Tips: HTML Snippets with Twig Macros

Sculpin is a PHP-based static website generator, ideal for powering websites that don't need dynamic DB-driven features or web-based administration. It's commonly used for blogging, but can be used for pretty much any marketing site you need, such as corporate websites, online portfolios, or even emergency downtime pages for when your WordPress site has been hacked ... (Kidding! Proper maintenance and security practices will make WordPress downtime a rarity.)

When running a website, you'll often want to reuse snippets of HTML. Many editors and IDEs have this functionality built in, but the problem with using editor snippets is maintainability. If you want to alter the snippet, you have to suss out every place it was used and manually edit it.

Sculpin uses the Twig templating engine, which has a feature that solves this problem. Twig macros are kind of like functions, like you would find in PHP or Javascript. They can be a bit tricky to get started with, so check out the tips below for help.

Read more of this post »

July 21, 2015

Tags: dev, development, coding, howto, twig, sculpin