Implementing Abstract Classes and Interfaces with Traits

There are some very helpful ways to organize classes and objects in PHP. Interfaces, Traits, and Abstract Classes can work together to make code that follows the rules of abstraction. Using these OOP features in PHP allows us to create code that is easy to extend and maintain, saving time and money down the road.  Let’s look at what these structures are as well as how and when abstract classes, traits, and interfaces can be useful in Object Oriented PHP.

Generators in the Real World

Generators are one of the coolest things in modern PHP! They were introduced in PHP v5.5 and expanded even more in PHP 7.  I’ve read a lot about concurrency and how many event loops utilize these generators to interrupt code to do a little bit of everything at (seemingly) the same time.  However, this is not the most useful point of generators in typical PHP applications.  Let’s take a look at a couple ways that Generators can make life easier in typical, synchronous, PHP applications.

Living with Legacy Code

Chances are you have some legacy code that you have to deal with.  If not, then I’m guessing you haven’t been programming very long and are doing everything on your own.  Legacy code is old code – it uses older technologies, generally has some technical debt, and takes longer to modify than packages you create from scratch.  Since we all deal with this, but to some varying degree, I’m going to approach the topic as if you are coming into a project that may not be your own and is rather old and clunky!

Getting Advanced with Variables

Variables are pretty straightforward in PHP. Anything that starts with a $ is a variable.  However, there are some things about them that can be somewhat confusing.  Let’s do an overview of Variables in PHP. Type Juggling In PHP, variables will automatically convert to whatever type is needed.  Most of these transformations are very natural and it allows programmers to spend the majority of time working on the application logic.  However, every now and then some of the automatic conversions can get you in trouble if you’re not prepared. For example, if you try to multiply an integer and a …

WebSockets and Ratchet

WebSockets have been around for quite some time, but are recently gaining a lot of popularity due to their ability to initiate messages from the server to the user, allowing the website to update on the fly! In this article I’ll be taking a look at what WebSockets are and how you can implement them using asynchronous PHP and Ratchet.