PHP is a widely-used programming language for building websites and web services. In November of 2020, PHP 8 was released. This version introduced major performance improvements over PHP 7.

Modern PHP Development

Modern applications built with PHP use Composer to install packages and an autoloader to load those packages. They also adhere to popular standards know as PHP Recommended Standards which are published on

  • PSR-4 - Autoloader: Describes how namespaces and classes must be used so that they can be autoloaded
  • PSR-7 - HTTP Message Interfaces: Describes specifications for HTTP requests and responses.
  • PSR-12 - Extended Coding Style Guide: Describes coding styles related to line limits, indentation, file endings, class properties and methods, and certain keywords

How I Use PHP

I mainly use PHP to build business applications using the Laravel framework. I run PHP on Linux environments, typically Ubuntu. For unit tests I use either PHPUnit or Pest.

I write most of my code within PHP classes which are instantiated into objects when the code is executed. Laravel has specific types of classes like models which inherit the provided "Model" class. Laravel's documentation provides examples for creating and building out these classes. I often use Artisan, the command line tool, to create these files so I don't have to copy and paste or type them out.

Although I'm capable of building applications without Laravel, I find that nothing I build is simple enough that I can justify forgoing a framework altogether. I don't use PHP to write single-purpose, isolated scripts. I use PHP to build scalable, dynamic applications that need to handle HTTP requests, store and retrieve files, output HTML from templates, and interact with a database. Laravel provides all of these tools in a nicely packaged framework with good documentation and support from the community.

There are principles that I follow that transcend frameworks and even programming languages. When the code starts to feel like it's becoming overly complicated, I think "Keep It Simple Stupid" (KISS) or the "S" in SOLID which stands for Single Responsibility Principle. When functions are simpler they're easier to understand and easier to test. This also helps when naming variables, functions, classes and methods. I want my function names to be descriptive so if they start getting a little long, sometimes that's an indication that the function does too much. For example, a function called createUserAndSendEmailAndNotifyAdmin() describes what it does, but it would be better change the function to just createUser() and put the other code into separate functions so they each do just one thing.