Arrays in PHP…Because there are no hashes/dicts

Say What Now?

I’m brand new to PHP. Every other language I’ve worked in has had the concept of a hash/dictionary/object, separate from the concept of an array/list (though, yes, lots of names for the same general idea…I’m going to use the word dict going forward, but I also mean the hash, map, Object, etc. that you’re familiar with).

So I was pretty surprised to learn that the concept of a dictionary doesn’t exist in PHP. They’re useful, and they’re way more time-efficient than arrays in some use cases. So…how does this work?


If you’re being blocked by Medium’s paywall, this article and all its links are also available here.

I’ve been writing about (and working in) Django for almost five years now, and I’ve written a lot about specific pieces of implementation. But as I’m about to move into a new role that won’t be using Django anymore, I want to take a step back and look at how it all fits together.

This post is largely a compilation of links to both the documentation, as well as posts I’ve written about various topics related to running Django at scale in production…


Encryption is a huge part of modern software engineering. This is true both of data within our own systems, but also encryption of data we send or receive with network requests, to ensure the security of data in flight and the validity of data received from other services.

Most modern languages have libraries or built-in functionality that can be used to implement encryption for us, so knowing the ins-and-outs in depth isn’t necessarily a prerequisite of working in parts of your system that use encryption. …


I had never heard the word “idempotent” when I started at my first software job. I had a liberal arts education and had been working in nonprofit and school management before my career change. I suspect I’m not alone in this total lack of awareness of the concept! So let’s talk about it.

What does it mean?

It means you can do the same thing with the same inputs any number of times, and it won’t change the end result.

This is easy to achieve when we’re talking about data retrieval — retrieving data doesn’t change the data itself. But it gets a little…


When many of us are first taught to program, we’re told something along the lines of “programming is a set of very specific instructions that a computer follows in a specific order.” And this is true, sort of. It’s true, but it’s incomplete. What that statement ignores is that when we’re programming for the web, we’re usually dealing with more than one computer.

Multiple computers run our application servers. We use microservices. We have databases and background tasks and message busses and scheduled jobs.

These are the high-level things I wish someone had told me when I first graduated from…


(+ some common gotchas!)

Overview

I’m mot going to do a deep dive into cookies and their use in the web on the whole. If you think an introduction like that would help you understand this post better, here is one place you might start.

The very high-level that will apply to what we’re going to talk about here is this:

  • Cookies are stored by your browser
  • They’re basically key-value pairs, with some attributes
  • Your browser sends relevant cookies along with requests to your server.
  • When you send a response back to the browser, you can tell it to set new cookies, or update existing…


No matter how hard we try to get our data model correct (and even if we’ve done so!) sometimes by the time we need to use it, either for a public-facing API or an internal one, we need things to look a little different. Django Rest Framework(DRF) has some useful tools for allowing us to build serializers based on our models that differ somewhat from how we’ve defined things internally.

For our example, we’ll say we have a data model that looks, in part, like this:

class Item(models.Model):
name = models.CharField(max_length=255)
...
class Offer(models.Model):
item = models.ForeignKey(Item)
...
class Purchase(models.Model)…


Unless a website is static, it almost certainly connects to other cloud services such as databases or caches that are hosted on servers other than the ones on which main application is running. Connection strings are used to identify where to find the server running the service, what type of driver to use (Postgres, Redis, AMQP, etc.), and what credentials to access it with.

At first glance, they can look like nonsense and be difficult to parse, but the good news is, there’s a logic behind it all! …


Models are the way we tell Django what we want our database schema to look like, and are the things through which we interact with rows, or instances, in our database.

One of the benefits of using a framework like Django is that it provides functionality making it easier to create and interact with our data than if we had to do so directly with the database and generate and validate our own SQL statements. This means that there are things that will look different in the database than they do in our code — this is okay! …


If you are interested in updating the name of the primary branch on your repository from master to something more inclusive (I’ll use main in my examples here), but are unsure because you deploy your app via Heroku pipelines and aren’t sure how easy that will be to change…the good news is: it’s very easy!

Before doing the below, I followed the instructions here to update both git and GitHub.

Open your pipeline in the Heroku dashboard, and for each app with automatic deploys configured, choose Configure automatic deploys…

You will then need to disable the automatic deploys (this will…

Adrienne Domingus

Senior Software Engineer | www.adriennedomingus.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store