Never miss a beat

Join my newsletter.

Tag: php

Arrow Functions in PHP 7.4+

Published: 3/31/2020

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…

Building a simple URL Shortener in PHP with Laravel

Published: 3/12/2020

I’ve recorded a quick Youtube video for you! In this video, we walk through building a simple URL shortener (think 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…

How to read from a file in PHP

Published: 3/9/2020

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…

What is Laravel's Homestead?

Published: 2/29/2020

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…

PHP: Add to an Array

Published: 2/1/2019

It’s very common to find yourself working with Arrays in any language, and PHP is no exception. If you’re reading this, you probably want to find out how to add to an array in PHP but there’s one thing to cover first! Unlike most other languages, arrays in PHP are just an ordered map! Let’s declare an array to work with. Arrays can be declared similarly to map, but you can freely omit the keys. Now that we have an array, we can see how easy it is to add to an array like so: Adding to an array in…

Building a Simple API in PHP using Lumen

Published: 1/22/2017

Alright, at it again with another PHP post. Hopefully this doesn’t dislodge my blog from the newsletter from writing too much non-clojure. The other day I wrote a post about using Slim with Eloquent to build a simple API. It was a fun project and I decided to share it with the PHP subreddit. Thankfully, the PHP community is far better than I remembered it — we created a lot of great feedback and had a few discussions about Lumen . What is Lumen, you ask? Well, it’s a…

Building a Simple API in PHP using Slim & Eloquent

Published: 1/16/2017

I’ve been exposed to a lot of PHP recently! I’ve been reviewing a course on functional PHP for a publishing company (link will be added once it’s released) and my friend has recruited me into working on an API that’s written in PHP using the Slim framework. I figured now would be a good time to write about my recent findings! Slim is a microframework , similar to Flask or Sinatra but for PHP. I’ve been pretty reserved about PHP in the past (It was the first language that I was paid to write…