October 2016 Newsletter

Word for the Herd

2016-10 Solve

Let me explain. Recently I was charged with creating 50 documents from a database and then printing them out. Simple enough if you are working with a language that supports printing to printers, but PHP isn’t really designed to do this. So I did what PHP is good at, I created 50 HTML files.

Next I had to get these to the printer. Ok, there is still no real good solution to do this programmatically. Also, I implemented some CSS to put a footer at the bottom of each page. Whatever solution I came up with needed to print this properly. That means i need a very good browser engine that supports modern CSS to properly print these documents. Through experimentation I realize that I can simply open each document in Firefox locally, click print, change a few settings because FireFox is incapable of saving presets, and then save to PDF. Boom printable document, right? Yes, it meets all the requirements except scriptable. Honestly, who wants to sit there, open 50 documents individually, and save to PDF. Afterall, I am a programmer, I should be able to bend the computer to my will.

Friday morning rolls around and I am caffeinated and cranking my tunes, I can solve this. In the immortal words of Jax Teller from Sons of Anarchy, “I’ve got this.” To cut a long story short, I spent Saturday morning opening 50 html documents locally and creating PDFs of them using Firefox.

I managed to find about 10 good ways not to do the job. At one point, I was experimenting with macOS automator to create a script to automate the procedure. Nothing worked.

I tell you this story to explain the tweet above. It is a cautionary tale for developers. See, I HAD a solution. I could have use FireFox on Friday, got it done, had the rest of Friday to get other things done. Instead, I stubbornly insisted that I could do this I could script this one-off task even if it was going to take me longer than just doing it manually.

Programmers love creative solutions. We love creating clever solutions, even if they look like Rube Goldberg’s when they are done. Even if there are simple solutions available to us. We love to explore new ideas and technologies even when the problem can be adequately solved with existing tools and techniques.

It is a great time to be a programmer. There are new languages, concepts, packages, and even package managers, being released all the time. With all these options, many times new problems look to us like an opportunity to explore a new tool, learn something new. Sometimes though – many times – new problems are just an opportunity to solve the problem as quickly as possible so you can move your project forward.

As much as I love and encourage learning, don’t get caught in the trap. Sometimes you need to apply what you’ve already earned and just solve the problem.

Cal Evans
Nerd Herder for the World Wide Herd

The InPHPormation You Need to Know

Current Versions of PHP
(Make sure you are up to date!)

Article Suggestions

The MIT License, Line by Line
Kyle E. Mitchell

A Review of Bulgaria PHP – Game On!
Bruno Skvorc

Database Tests With PHPUnit
Tobias Schlitt

How to Build a Docker Test Environment
Matthew Setter

Episode 012 – Conference Talk and Tutorial Tips
Adam Culp

Use The Symfony Workflow Component
Vincent Composieux

Destructing PHP
Johannes Schlüter

Lesser Known Git Commands
Tim Pettersen

Last features in PHP 7.1 (part c)

Interview With Jeremy Mikola
Cal Evans

Hourly vs Value-Based Pricing
Sammy K. Powers

Episode 17 – How To Build a Docker Test Environment
Matthew Setter

Anatomy of a Dope PHP Package Repository
Raphael Stolt

PHP 7 on macOS Sierra
Michelangelo van Dam

Microsoft SQL Server from PHP
Remi le mardi


October 29, 2016 · Edinburgh, Scotland

November 14-18, 2016 · Washington, DC

ConFoo Vancouver
December 5-7, 2016 · Vancouver, Canada

PHP Benelux
January 27-28, 2017 · Antwerp, Belgium

Sunshine PHP
February 2-4, 2017 · Miami, FL*

PHP UK Conference
February 16-17, 2017 · London, UK

Confoo Montreal
March 8-10, 2017 · Montreal, CA

* = Cal will be in attendance and have Nomad PHP stickers.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>