Bite Sized Code Refactoring – Redundant DB Connections

I maintain and work on a number of legacy code applications. One of them has earned itself some refactoring. So I’ll try to share some of the changes I’ve been making to improve it. Today, a problem that’s bothered me for a while: the DB class connects to the database even if no queries are being used.

I should be thankful that this legacy app doesn’t have a bunch of mysqli_* calls all over the place. Back when I wrote it I at least had the presence of mind to wrap SQL functions in an abstraction class. So this change was quite easy to make.

Continue reading “Bite Sized Code Refactoring – Redundant DB Connections”

How To Learn: Composer

Our How-To-Learns are concise articles with information about how to learn various tools, techniques, skills, etc. These articles won’t teach you directly, instead they’ll make it easier to find authoritative, up-to-date, and relevant information to master the topic.

Intro

For the past several years…. ok, maybe a decade… I’ve been happily growing my personal, private collection of reusable PHP classes, plugins, libraries, modules, themes and even frameworks and a CMS. All coded by me, from scratch. Imagine my excitement – and more than a little embarrassment – when I discovered Packagist and the amazing tool of Composer which pulls the libraries published on Packagist into your project with a snap. It’s beautiful. And it’s become the industry standard along with the autoloading library it comes with. How can we learn Composer? Continue reading “How To Learn: Composer”