Skip to content

Category: Tutorials

Bringing OOP functionality into WordPress

So if, like me, you’re an object orientated programmer and are suddenly asked to build functionality into WordPress it can feel like you’re trapped into procedural code and functions. Consequently; I thought I would whip up a little tutorial of how to work within WordPress, whilst maintaining your OOP integrity. The reason this is important is quite simple, if you’re building complex functionality into WordPress, you want to be able to use OOP principles and methodologies. Don’t worry or get confused, themes vs plugins Essentially, these are the same thing! They use the same library of code, the APIs you…

Leave a Comment

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…

4 Comments

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