Skip to content

Johno the Coder Posts

Quick and Easy PHP Singleton

Hi guys A really short one today, just because someone asked me about it a couple of days ago. I also though it potentially best to avoid something as controversial as my last post about Eloquent and the Single Responsibility Principle, which caused a bit of a stir during the week. So, you want to make sure you only ever use one specific instance of a class (maybe a DB connection) and need a quick and easy way to do it. Personally, this is the technique I would use: <?php class MySingleton{ // This will hold the instance of the…


When to use GitHub, when to use BitBucket

This is always a bit of a hot topic, especially amongst teams just getting ready to start properly managing their code through remote repositories. Disclaimer: I’m only going to talk about GitHub and BitBucket in this article. If your code is your bread and butter, your only offering; you probably should consider hosting your repositories yourself. I’m also sticking with these two as they’re the most widely adopted. When should I use GitHub? GitHub can be found at – shameless plug, my user on there is @johnothecoder Short answer: For anything/everything open source, or where you’d hope for community…

Leave a Comment

How Eloquent breaks the Single Responsibility Principle, and why I’m okay with it

Hi everyone I thought I would discuss a controversial one today, in order to give an articulated response to a common argument about Eloquent (and generally the Active Record pattern) Firstly, just in case you don’t know, here are some definitions: Single Responsibility Principle: The “S” in the “SOLID” principles. In short, this means one class should have one job. The idea is to keep your code modular and easy to switch out. SOLID Principles: I’ll do an article on this one day, but it’s a discussion for another time. Like all principles or methodologies they’re like the Pirate’s Code, they’re more…

1 Comment

Using Git to effectively manage your code

Hi everyone This time I thought I would give a quick insight into the ways which I have found to be best when working with Git. Especially if you’re in the position where you’ve never had to manage or decide the direction of how to use source control. I’m sure you all know the benefits of source control, whether Git or other, but I thought it would be worth highlighting them anyway: Structured, integrated development (that is, you can have multiple people working on the same project/release at any given time) Simplified deployments Easy way to track where your code…

Leave a Comment