Skip to content

Month: September 2017

Quick Life Hacks with the Eloquent Model

Hi folks, It’s no secret that I love Laravel, and especially love Eloquent. This post isn’t about why various people don’t like Eloquent, etc, etc. but just some “life hacks” of working with Eloquent. #1 – Naming Conventions I personally like to use the following naming convention on my databases (using a forum as an example) forums forums_topics forums_topics_replies Whereas Eloquent would expect the following: forums forum_topics forum_topic_replies I personally dislike this, for no other reason than I like to be able to see what’s being owned by what at a very quick glance. Additionally, namespacing; I like to namespace…

Leave a Comment

You are the worst programmer in the world

You, yes you, are the worst programmer or web developer in the world. Without a shadow of a doubt. In someone’s opinion. The thing about programming or building anything is that it’s almost entirely subjective. Of course there are certain things which are categorically bad like lazy developing, obvious bugs, security vulnerabilities and terrible performance (both server side and client side). The point of this article, really, is to ask the question: Why are we, as a community, so judgemental? There are plenty of controversial topics, when you get into web development. Factory patterns vs dependency injection vs just using classes/objects.…

2 Comments

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

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 github.com – 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