Setting up Laravel Valet + MySQL via Homebrew

After far too much delay, I’ve finally ditched MAMP Pro. It’s taken me too long really, that software is decidedly… not nice.

I’m now trying Laravel Valet + MySQL via Homebrew for local PHP development on my MacBook Pro. See notes below for future reference. I had some fiddly points getting started and expect there to be more, but am pretty pleased with the change overall.


0. Back up databases

The pre-step is to back up any preexisting databases so that you can set them up later if needed. Personally, I use Sequel Pro for all local and some remote database management, so I pulled my necessary exports from there.

1. Install and configure Laravel Valet

The first step is to install Laravel Valet. Their installation docs are pretty much all that is needed. The only caveat is that I’d be a little careful about updating Homebrew or Composer willy nilly, just be wary if you already have it installed and need your preexisting version for any reason. While completing the installation steps, pay attention to the warnings! Complete any recommended steps if you can, they pop up for a reason.

If all went well, at this point you should have an Apache server so you’d be ready to work on a file-based website such as one that uses Kirby CMS or a static site generator (Hugo, Gatsby, Jekyll, etc).

2. Install and configure MySQL with Homebrew

To work on a database-driven site like a Craft CMS or WordPress build, the next step is to install MySQL via Homebrew.

The Laravel Valet docs mention this step, but for me it was nowhere *near* as simple as their two-command recommendation. I think there was likely a conflict with my preexisting MAMP-specific MySQL setup and possibly an old Homebrew installation. I ran the commands from the Valet docs to install MySQL v5.7 and run it, but I would get the error The server requested authentication method unknown to the client [caching_sha2_password] on the front-end. This error indicated that it was actually running MySQL v8 (read more). Sure enough, mysql --version returned mysql Ver 8.0.16 for osx10.14 on x86_64 (Homebrew). To sort it out, I had to reinstall and restart the MySQL service.

To remove MySQL, I followed these instructions. (Be careful with those commands, they remove a lot of stuff.)

After I’d gotten rid of MySQL, I ran the commands below to install, link, and start the service.

brew install mysql@5.7
brew link --force mysql@5.7
brew services start mysql@5.7

Note that I tried doing this without the link but consistently ran in to the error Can't connect to local MySQL server through socket '/tmp/mysql.sock' when trying to connect in the next steps. Linking seemed to sort it.

After this, I followed the installation’s recommendation and ran mysql_secure_installation. This is so that we set the root user’s password since it is required for phpMyAdmin and Sequel Pro (coming up next).

3. Set up and / import databases

Once MySQL is set up and running, it’s time to configure the databases. To do this via the command line, run mysql -u [username] -p [databasename] < [filename.sql] (replace bits in brackets) and when prompted, enter the password you set up via mysql_secure_installation.

Otherwise, you can do it via a UI such as phpMyAdmin (see Laravel Valet-friendly steps) or Sequel Pro.

4. Adjust PHP settings (optional)

I usually adjust my PHP settings (e.g. memory_limit, max_execution_time, post_max_size, etc.) per-project so that they’re closer to the site’s production hosting environment. I thought it would be as simple as adjusting the php.ini file that is specified in the “Loaded Configuration File” value returned by phpinfo(). I edited /usr/local/etc/php/7.2/php.ini and then ran valet restart to restart the server and… it didn’t work. One of my changes was respected according to phpinfo(), but the rest weren’t.

I checked the “Additional .ini files parsed” value and saw that the file /usr/local/etc/php/7.2/conf.d/php-memory-limits.ini was also in use. After I edited this file to include my preferred settings and restarted Valet, all was well.

5. Adjust Nginx config (optional)

Valet’s default Nginx config should normally be sufficient, but you might have to tweak it for certain edge cases.

My edge case was the British Earways site (read more). I was working with it locally and suddenly ran in to a 413 Request Entity Too Large error when attempting to upload a very large audio file. To get around this, I needed to raise the client_max_body_size Nginx directive.

To adjust the Nginx configuration, I first had a look at the main config file by running /usr/local/etc/nginx/nginx.conf. Scanning through that, I saw a few includes:

include "/Users/[username]/.config/valet/Nginx/*";
include servers/*;
include valet/valet.conf;

I had a look at valet.conf, found client_max_body_size and changed that value to suit my requirements, and then restarted the server by running valet restart.

Other useful things

  • Run brew services list to find out which services are running. This is useful for troubleshooting if you’re having PHP or mySQL errors.
  • If you’re adjusting the PHP settings in a .ini file, run valet restart, and then suddenly start seeing only an “It works!” screen where your site should be, you probably have to stop Apache first before restarting Valet. Most guidance online recommends running apachectl stop, but I had trouble with this (see related StackOverflow thread). Instead, I ran valet stop, sudo killall httpd, then valet start. This worked smoothly
  • Here’s a list of MySQL commands.
  • For more info about what $PATH is and why it’s important, see this Unix & Linux Stack Exchange thread.
  • I usually use redirect rules to use media from production when developing locally. Laravel Valet doesn’t seem to play nice with the normal .htaccess method, maybe because it’s actually an Nginx server. See “Proxying images to a remote host on Laravel Valet” for an effective alternative.

Edit 10 July 2019 – Added further notes based on working with Laravel Valet the past few days, including the PHP and Nginx config adjustments.

Nan-nan’s cupcakes

Looking through Nan-nan’s recipe books, the first thing that caught my eye was a recipe for cupcakes from her sister June, see below. I’ve preserved her notes and phrasing as much as possible but have adjusted certain elements to be more usable.

I’m an OK baker but more of a pies-and-cookies person. Every cake I’ve ever made seems a little meh. These were not meh, 10/10.


Cup Cakes

From June, Merle’s favorite. Good with baked icing or white fudge icing. Makes 12.

Preheat the oven to 350F (175C).

In a large bowl, cream together ½ c (113 g) softened unsalted butter, 1 c (200 g) sugar, ½ t salt, and 1 t vanilla extract until very fluffy and light. Next, beat in 4 egg yolks until thick and light in color. In another bowl, sift together 2 c (230 g) all purpose flour and 2 t baking powder. In small, alternating amounts, add the flour mixture and ⅔ c (158 ml) milk to the butter mixture. Beat after each addition, until smooth.

Pour the batter in to a lined cupcake tin, filling each cup ⅔ of the way. Bake in a moderate oven, about 350F (175C), 25 to 30 minutes. Turn the tin once halfway through if you find one side is browning more than the other.

Additional notes

Note that the cupcake recipe originally calls for Spry, a vegetable shortening. I’ve substituted butter here since that’s what I’ve got.

The original recipe also specified 2 c of sifted flour, with an additional note that specified Gold Medal or Swans Down flour. Gold Medal is usually plain / all purpose flour, and Swans Down only produces cake flour AFAIK. This made determining the metric measurement kind of ambiguous, 2 c sifted all purpose flour is significantly different than cake flour. The measurement below worked well ultimately, but I’d like to try cake flour eventually so will need to keep this in mind.

She originally said it makes 18, but I found that it is much closer to 12 in a 12-cup cupcake tin with cups that measured 2″ (4.25 cm) in diameter across the base. The flour debacle might have caused the difference.

The cupcakes supposedly go well with “baked icing”, something I had never come across before. I tried it with baked frosting and failed *spectacularly*. I can see that it could be great though, kind of like a molasses-y meringue on top, so I’ll try again and note here if successful.

Nan-nan’s recipe books

Handwritten recipes by my paternal grandmother

My cousin kindly let me borrow my paternal grandmother’s cookbooks for the next few months until we meet again in August. One is a comb-bound cookbook assembled by the community of Worthington, OH. The other is more of a diary where she recorded her favourite recipes. I had NO idea that these books existed. I had always been told she didn’t keep track of her recipes, so this is pretty exciting.

It’s going to take a while to go through the cookbooks, so I took some rough photos of all of the spreads in case I don’t get through it all by the time I return them. It’s classic late 20th-century Midwestern fare. Most of the pages are dedicated to sweets of all sorts, and there are a fair few recipes that call for Velveeta cheese, Jello, or Campbell’s cream of mushroom soup. I’ll probably steer clear of the gelatine “salads” and sadly have to avoid the cheesiest of things, but I’m up for everything else!

I’ll share some of Nan-nan’s recipes in future notes as I try them.

britishearways.com

Screenshot of britishearways.com

Last month, I completed a major overhaul of the British Earways website. The design by Valerio di Lucente of Julia is almost entirely unchanged, the adjustments were largely performance-related and under the hood, geared towards modern browsers. Here’s brief rundown of the changes:

  • Style the full-window player layouts using CSS Grid Layout + 100% height (not 100vh since that can lead to unexpected behaviour on mobile browsers), and use CSS Scroll Snap w/ polyfill for scroll behaviour
  • Achieve flexible typography and spacing with “CSS Locks
  • On non-touch screens, implement invisible DragDealer instances so that each player’s scrubber can be dragged
  • On touch screens, add click event listeners that advance the relevant scrubber to the click target
  • Use styled HTML5 progress elements for each player since these are easily manipulated via their max and value attributes and don’t require adjustment if the window is resized
  • Use the Web Audio API to initialise each audio file and trigger the necessary state changes as the time updates
  • Switch the audio preload attribute from auto to metadata to reduce the size of the page when it initially loads
  • Update CMS to Kirby 3 (this was a joy, IMO the panel layout options make v3 much more client-friendly)
  • Adjust post_max_size, memory_limit, max_execution_time, and upload_max_filesize to allow upload of large (150MB+) audio files

I ran in to one issue that isn’t yet resolved. Kirby copies all uploaded media from the private /content folder to the publicly-accessible /media folder. This copying normally happens almost instantly, even with very large files. On the BE site however, the copy is pretty slow. Since the site pulls the audio duration from the audio file itself via the Web Audio API, the displayed duration is incorrect until the file has finished copying. This is almost certainly related to some rate limiting done by the shared hosting company, a legacy from the preexisting site. It isn’t a huge deal since the copying always finishes eventually, but it isn’t the best behaviour. I’d like to raise the issue with the hosting company but don’t have high hopes, shared hosting providers use rate limiting for a reason.

At any rate, I’m really looking forward to seeing how DB uses the site over the next year and listening to the new mixes.

TODOs: automation, films, pens, reading, etc.

This week has been absolute chaos. Good though! A few things to remember, and to follow up on.


I keep coming across Automate the Boring Stuff, and keep forgetting to look in to it. Python was the first language I learned back in college with Prof. Maxwell, so would be nice to revisit it.

Same thing with films like Idiocracy and The Skeleton Twins. Made a mental note to see them years ago and then promptly forgot, so I’m noting them here as an ever-so-slightly more effective reminder. Idiocracy seems particularly weird, on paper it should have been a huge hit but it got absolutely sidelined by Fox and was screened in the bare-minimum of theaters. The reviews are crazy mixed. Still, I’d like to see it.

Something I *have* watched recently on SB’s recommendation is the BBC’s Ghosts. It’s hilarious and completely charming, a lot of the same faces as the original Horrible Histories but a completely different format. I’d watch the whole thing again, hope they do another series.

Last weekend was Offprint book fair in the Turbine Hall at the Tate, and probably my last event with OP. It was nice to see a few familiar faces including the guys at Here Press. Richard Hollis did a talk to a full house on his newest book about Henry van de Velde followed by a book signing at OP’s table. It was nice to see him again. He was using a blue Uni-ball Air for the signing. I’m going to keep my eye out for that one in the stationery shops, it’s a ball point that writes like a fountain pen (line thickness varies with pressure, but very little risk of leaks). The price seems super reasonable, the web’s retail giant offers a three-pack for just under £5.

GC recommended The Mushroom at the End of the World, and if there’s anyone I trust to give me great book recommendations, it’s her. I’m just hoping it leans towards the glass-half-full end of things, I’m not sure I can take more pessimism right now.

I might have a little bit of downtime while travelling over the next few weeks. If I do, I’m hoping to spend a little time looking in to Commotion, “a free, open-source communication tool that uses wireless devices to create decentralized mesh networks”. Could use SiteSucker to grab all of the docs before I leave for offline reading. I came across Commotion for the first time via a link to Learn Networking Basics from Measurement Lab’s learning resources.

Big data? No thanks

Gandi published a long blog post titled “Mass manipulation and platform privacy: where we’re at”. It’s summarises some talks and Gandi’s perspective following a conference on “democracy in the face of cybersecurity threats”. I’d like to follow up on a few of the points from the post. I’d also like to find out what public educational efforts are under way. Surely someone is working on PSA-style messaging about the dangers of misinformation and how to identify it. It’s easy to be skeptical about that sort of thing, but it can stick. What’s the cyber-awareness version of “Only you can prevent forest fires” or “A slip of the lip will sink a ship”? James Bridle’s “Big data? No thanks” is related, but the version I’m talking about is more personal, about confronting your own confirmation bias. But not too ominous, also catchy and friendly? Tall order.

Every time I sit down on the tube I wonder about what other people see when they look at me, what they perceive about me precisely because they are *not* me. There is this slippery divide when it comes to understanding yourself. There are elements of yourself that you can never understand since it’s impossible to get outside your own head (one of the reasons that talking to someone else about a problem can be so helpful). There are other things about yourself that only you can ever understand, no matter how much time you spend attempting to express that thing. I have trouble articulating why this feels like a catch, but surely someone out there has tried. Just need to find them.

Could NemID exist in other countries? And should it?

Front of a NemID card

Last Monday, I met with some friends at the Cock in Hackney. One of them had just returned from Copenhagen and mentioned having to sort out something related to his NemID. I’d never heard of it before.

Apparently NemID is a common login tool that Danish residents use to access online banking and services offered by public institutions. It’s a little credit card-sized booklet of 148 key pairs that you use alongside a user ID and a password. It’s like an analogue version of two-factor authentication. Each time you log in to something with NemID, the key pair you use is invalidated and is never used again. When you’ve used up all of your key pairs, you’re sent a new NemID booklet.

It seems like a great system. Unlike biometric data, it would be easy to replace if it were compromised. Unlike most other two-factor authentication methods, it doesn’t require an additional (usually smart) device of some sort.

There are downsides though. NemID is administered by a single organisation, Nets DanID A/S, and all of the data seems to be held in one place. This was a problem in 2013 when a DDoS attack knocked it offline temporarily. The oversight also seems pretty iffy, see this January 2016 blog article: “NemID is not cryptologically secure – and the authorities do not care”.

It’s also hard to say how this could be rolled out in countries with larger populations… Denmark’s population is around 5.7 million. That’s a bit more manageable than the UK (~ 66 million), Brazil (~ 209 million), or India (~ 1.3 billion).

Apparently NemID is going to be replaced by MitID in the next few years, so it will be interesting to see if the Danish government forces any changes to make the system less centralised.

And it makes me wonder (again) if something like Dark Crystal could ever work on a national scale.

Assertive Californian seeds

Graphite drawing of a filaree seed

In southern California, there are a few seeds that assert themselves in late summer as things get drier. A lot of prickly, pointy things that stick to you or make themselves known in more painful ways.

Graphite drawing of dried burclover

A few of them were fun to play with as a kid. If you pick at the center of a dry burclover seedpod and pinch the end of it in your fingers, you can pull it away until all that’s left are a few seeds and one long coil of tiny spikes. Filaree seeds wind up tight to make a little drill when peeled away from the plant. And you can make foxtails travel on their own if you put your forearms together from wrist to elbow, hands facing up, and then have a friend place one on your wrists with the point facing you. Rub your forearms back and forth and it will travel down your arms.

Graphite drawing of puncturevine or Goats Head seed

But some seeds were just annoying. If you went for a walk through a field, chances are you’d come out with your socks and shoelaces absolutely covered in hedge parsley hitchhikers. Sandbur and puncturevine were the worst. Puncturevine has a few other nicknames. Goat’s Head, for the shape of the seed pod sections, and caltrop. It often grows on the dry, sandy areas near the beach making it particularly perilous for the bare-footed.