Skip to content

Category: Tutorials

PHP Interfaces, Traits, and Inheritance, how and when to use them

Hi all So this one is going to be fairly short and simple, I hope! What I am going to cover, and this does assume so prior knowledge, is what interfaces, traits, and inheritance are; and some different use cases for them. So the first one, and maybe the easiest one to cover, first: Inheritance In its simplest term, and I’m going to try and keep things simple in this article. In very brief terms, inheritance is about extending something which exists. Of course, you may well have created this base on which you’re extending. Simple use case: User class,…

Leave a Comment

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…


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

Setting up Private Packagist & BitBucket or GitHub

Hi all This is a really quick tutorial, because frustratingly I couldn’t find one that offered me this quick guide that had an integrated approach to doing this. I’m going to mostly cover the bits that I had to learn myself through Googling etc. in the hope that you won’t have to waste hours on Stack Overflow and so on trying to figure out how to get it working. I’ve used composer a million times, but always as a consumer, not as a publisher. Least of all as a publisher on private packages. This tutorial makes a couple of assumptions:…

Leave a Comment