Arrow Functions in PHP 7.4+

PHP is finally getting arrow functions (also known as Short Closures)! I know, I know. I’m just as excited as you are. Here’s everything you need to know about arrow functions in PHP. First, arrow functions are an approved RFC for PHP 7.4. If you’re using a version of PHP that’s lower than 7.4, you won’t be able to use arrow functions. Second, arrow functions can only contain one single expression. The goal with arrow functions (as stated in the RFC) is to help reduce verbosity and multi-line arrow functions are likely to cause more confusion than classic anonymous functions....

Building a simple URL Shortener in PHP with Laravel

I’ve recorded a quick Youtube video for you! In this video, we walk through building a simple URL shortener (think bit.ly) in PHP with the Laravel framework. This originally started as part of my Laravel foundations course (link coming soon) but I felt that we could quickly get through an example on Youtube, too. In the course, we dive into things and go a bit slower to really get a grasp on how everything works, but this less than 30 minute video should get you started down the right path. If you want to continue building upon this (and adding...

How to read from a file in PHP

Reading from a file in PHP is an extremely common problem to solve. You may keep configuration variables in an environment file, or perhaps you pull in HTML from another file. Either way, you need your PHP code to read the contents of those files. Good news: It’s actually a fairly simple task to perform! What’s interesting is that there’s actually quite a few ways to read from a file in PHP. We’ll cover two common cases here and talk about why you’d use one over the other. Heads up: If performance is a concern, you’ll want to read through...

What is Laravel’s Homestead?

Laravel is, as far as PHP frameworks go, extremely popular. In their guide, the Laravel community recommends you use Homestead as your local development environment. But what is Laravel’s homestead and why use it? Laravel’s Homestead Homestead is Laravel’s suggested development environment for building Laravel applications in PHP. Homestead is packaged as a vagrant box (a virtual machine) and is aimed to simply the initial setup of your Laravel project. Why use Homestead? Laravel actually has a fairly specific set of requirements that need to be met if you are to develop for it. Homestead bundles all of these requirements...

Developer Advocacy, JAMStack, Blogs, Twitch and more w/ Jason Lengstorf

Jason Lengstorf appeared as a guest on a recent episode of my Podcast, Design Doc. I’ve had a request for transcripts, so I tried an AI-powered transcription service and will post the transcript below. Unfortunately, it’s broken up into two separate pieces, but it should be fairly easy to follow. Brad Cypert (00:00): Thanks for tuning in for another episode of the design doc podcast. I’m your host, Brad Cypert. And today I have with me Jason Lengstorf. So Jason is currently a developer advocate at netlify. He’s worked with the Gatsby team. He’s big in the JAMstack community. He’s...

Deploying from Azure DevOps to DigitalOcean

Azure DevOps is one hell of a tool, but is it still an option if you don’t want to deploy code to Azure? Well, yes, although it is a lot easier to deploy to Azure than anything else. This makes sense given how the two integrate and are owned by the same company. However, I’m going to show you how I deploy from Azure DevOps to DigitalOcean. Deploying from Azure DevOps to DigitalOcean isn’t as difficult as it may seem. In fact, with Azure DevOps’ build pipelines and a few modules, you can deploy to most servers with ease. And...

Python Length of a List

When writing Python, it’s fairly common to find yourself working with lists of data. Usually, you’ll also find yourself trying to figure out just how my items are in that list. Thankfully, in Python, finding the length of a list is fairly easy. my_list = [1,2,3,4,5] print("The length of this list is:", len(my_list)) The key takeaway here is the len function that’s built into Python. No external library required! The len function takes in a sequence or a collection and returns the number of items contained within. This means that the length function has an arity of 1 and should...