2023 Laravel tip roundup – an incomplete list

Dozens of miscellaneous tips: https://laraveldaily.com/tips

Tighten’s Technical Debt Self-Assessment for Developers

Use Laravel Pint or Tighten Duster – they’re so easy to use (versus doing lots of manual PhpStorm configuration, for example) and you can add them as git pre-commit hooks which will only scan files that have changed, so they’ll be fast.

Pint is also useful for cleaning up things that used to be best practice, such as adding parameters to function DocBlocks, but which should now only be written directly in the code of the method itself.

The new Laravel Prompts are great. They are prettier (nice colours, borders and icons) and they neatly handle all the edge cases, including keeping the screen tidy if input validation fails and you need the user to enter an answer again, or if the script is aborted. There are placeholders and default options, and single and multi-select which support Vim keybindings. Each component is a namespaced function that is easy to insert.

If your app has no tests at all, start by doing some “smoke” tests to check all your main routes are functioning. These can be quite brittle.

Turn preventAccessingMissingAttributes on for your Eloquent models. (In dev only.)

Move from Laravel Collective to spatie/laravel-html if you haven’t already (in my experience you can convert <form> tags to plain HTML but you’ll probably still want the package for the convenience of coding select dropdowns and certain radio buttons and checkboxes.

In particular, check that you have @csrf on all your forms and directives like @method('PATCH') where you need them. If you can, write tests that your forms can be submitted. Use this automated Laravel Shift, it’ll save a lot of time but it definitely won’t do everything. You do need to test every form, unfortunately.

When writing tests in general, prioritise Feature tests over Unit tests. Save yourself time and increase accuracy by examining the view data you get back rather than using assertSee (which blindly scrapes the output). Laravel Dusk is handy for things you can only really check in a browser.

Using old hardware: if a Mac is no longer receiving software updates and consequently Homebrew is unreliable or takes ages to compile, consider using Macports instead, which, for example, still has the very latest PHP versions. (I found those were very quick to install and only MariaDB took 20 minutes+ to build from source.) You can also use artisan serve or even just PHP’s built in server (php -S). And for editing you have Nvim. I certainly wouldn’t do “serious development” an old machine, but it makes a great backup.

A short verbatim quote I enjoyed from Matt Stauffer’s “Laravel and in the enterprise” talk at this year’s Laracon (there’s plenty of other good stuff in the full thing):

“People imagine that if they do “API-first” they’ll build an API, they’ll build an SPA in front of the API, and later they’ll get a free mobile app API out of it and they’ll build the mobile app and it won’t be any work.

What happens in reality is it takes three times as long to build your web app as it would if you’d just used native technologies, you have to learn SPAs, you end up building an API that’s super, super super tightly integrated with your SPA and then one day if you do eventually maybe have a mobile app it turns out it doesn’t need the same API resources and routes that you built because you didn’t really build a true REST API you built one that served that SPA, and you just have a second API now.

So your web app took longer to build, it’s more complicated and you have two APIs.”

Matt Stauffer (Tighten)

(you can do a nice, simple SPA, including persisting elements like an audio player, with Livewire 3)

Uninstalling Techtool Pro reliably

The symptom here was continual unwanted SMART warnings from the “realtime protector” which didn’t go away despite turning it off.

Login to the Micromat site where you bought it from, and on the My Products page, redownload the installer.

Open it, as if you were installing the application – you will reach a step where you can custom the installation and switch from install to uninstall. Choose this and let it finish. And that’s it.

The system preference pane will be gone and you should no longer have any Techtool processes in Activity Manager.

The case for turning off UK emergency alerts (a cynic writes…)

(In short, my main objection is taking away the user’s ability to silence or set a lower volume.)

  • there are a limited number of scenarios in which such alerts will ever be useful in the UK: the most common problem – severe weather in all its forms (which is, apparently, the initial focus) – is already well covered by Met Office weather warnings and flood alerts.
  • We already have good protocols for getting emergency quickly onto broadcast TV and radio – along with numerous news websites. Unless you’re making a significant effort to avoid the outside world (in which case you could well have you phone turned off anyway) you’ll hear about things. Quickly.
  • Potentially incidents with release of chemicals where people need to be advised to stay indoors or keep windows closed? Or a problem at a nuclear power plant? But again, there are already procedures for this – e.g. auto-diallers.
  • In the event of terrorist incidents – such as knife / gun incidents as we’ve occasionally seen in the UK – you don’t, as the police well know, want to cause someone’s phone to make a very loud noise if they are trying to hide from an attacker (people have been in such situations).
  • The maximal volume, non-reducible, non-mutable prolonged (10 second) siren sound is needlessly unpleasant and unsuitable or unsafe in numerous other general situations. Simply because it’s likely to startle people and make them hurt themselves if they are doing something risky (driving, using power tools, handling hot or dangerous liquids, somewhere where you might bump your head etc.) Sirens in wartime were different because people weren’t nearly as close to them. A phone is something people often carry in a pocket. If an alert is ever sent at night – intentionally or by accident – all it will achieve is needlessly waking hundreds or thousands people who do not need to know about it. My biggest issue is the lack of volume control. I cannot think of a valid reason why these alerts shouldn’t be delivered at normal volume or silently. (Remember that deaf or hard of hearing users have the ability to activate a strobe light on their phone when they receive incoming messages.) This is, seemingly, an entirely arbitrary decision by Apple, which governments have failed to push back on – Apple could have allowed control over the volume, and as a result fewer people would be turning the alerts off, and Apple has varied certain security and network settings for different territories according to local laws (I can’t speak for the Android situation).
  • granted, being a cell-broadcast message, the alerts will work if a 3G/4G/5G network is congested and you otherwise would fail to get a web connection or make a call, however it won’t help where a phone is out of the coverage area
  • you can guarantee that every other UK news organisation will send you a notification the moment an official government alert is sent (including – prediction for 23 April – the highly-advertised test) – or provide blank coverage or TV or radio – so you will end up being told multiple times about whatever it is.

Is there anything the UK has got right about this?

Well they’ve done the advance publicity about as well as they could.

And this – https://www.gov.uk/alerts/current-alerts – is a handy page. (I’d quibble with why that can’t be in the top-level directory, but..) Also https://www.gov.uk/alerts/past-alerts, which tells you the time each alert began and ended. Well done GDS. Impressively GDS still supports IE8 too, which most of the rest of us web-developers abandoned long ago.

Tip: Mac SDHC/SDXC card readers wrongly showing cards as read only

This is quite common on older Macs. The symptom is you see the usage of the card but not the free space in the Finder status bar. It’s due to poor tolerances in the drive, perhaps dirt build up as well, although using an air blower didn’t help.

What worked for me was positioning the write-protect tab slightly “north” of centre – i.e. almost at the standard read/write position, but not quite.

Tip: When Amazon won’t cancel an order that’s “dispatching soon”

Occasionally you may need to cancel an Amazon (UK) order that’s “dispatching soon” – on doing this Amazon say they’ll “attempt” to, but then a short while later you get an email telling you in fact they can’t, and to refuse delivery or print a return label.

The solution in this case is to change the delivery to go to an Amazon Hub locker rather than your home address. This avoids you having to print a return label, then take it a shop (though, for the record, there are now printers in the some of the shops which are easy to use, and the shop will package it for you – in reality in my experience this means put it in an envelope – they don’t have a full selection of packing materials for fragile stuff).

Sending to a locker it means if the item is not collected within 3 days, Amazon automatically take it back again. Arguably this should be better from the merchant’s perspective (in the case of Fulfilled by Amazon orders) because the package hasn’t been opened, and Amazon are aware of this, so it should be able to go back on sale without further intervention or cost to them.

Curiously, in the UK this doesn’t appear to be possible from the website yet, only from the iOS app. But as soon as the order is visible there you can change it from your home/business address to an Amazon Hub.

In praise of Lightroom Classic

At present, there are two pieces of software that I consider superb – PhpStorm (a program by an astonishingly talented Prague-based company, which I use to write PHP, HTML, Javascript, CSS etc. and which error-checks your code to within an inch of it’s life before you even run it) and now, Adobe Lightroom[1]Although, as it happens, you really don’t want to run them both at the same time as they hog so much memory….

I briefly mentioned my admiration for the latter in a previous blog post. So much so, I regret not learning it until last summer. I have been getting into[2]That’s right, Flickr is still a thing. It also obeys my I’m-not-going-to-explain-this-very-clearly-am-I? theory of online communities – notably that they’re friendliest and … Continue reading photography again recently.

Lightroom gets quite a bit of stick, mostly for Adobe’s subscription model as much as anything, though the Photography plan – at £10 a month with Photoshop as well, is arguably a bargain. Here’s what I like about it[3]I should add I’ve not tried Capture One, which lots of people like:

  • All edits are entirely non-destructive and the whole history is retained.
  • They’ve made it near impossible to accidentally delete your photos: you have to reject them first, then specifically choose the Delete from Disk option, rather than the default “remove from Lightroom”. Even so, your RAW files are still in the macOS Trash. And on your memory card until you erase (or preferably, reformat) it, because, also, despite constant pressure, Adobe have refused to add any sort of command to wipe SDHC cards from within Lightroom.
  • Your catalogue files are backed up daily by default and you’re prompted to do this when closing the app. The catalogue backups are SQLite databases in clearly timestamped directories, which accumulate forever until you get rid of them.
  • Likewise, your photos themselves live in a directory structure entirely of your choosing – I went with /Pictures/yyyy/yyyy-mm/yyyy-mm-dd – which you can move anywhere on any drive. You do need to learn the basics of how Lightroom syncs files and folders, and preferably not start moving things around in Finder by yourself – ask Lightroom to move it for you so it doesn’t lose track of your files. But compare the clean and simple nature of all this to Apple’s latest obscure, proprietary incarnation of their Photos app, where everything is dumped in a huge hidden package file you fear could corrupt itself at any moment and over which you have little control.[4]Another reason not to use Apple Photos is how it insists on running an AI scan of your entire library which it’s impossible to switch off – although, small tip, opening the Photos app … Continue reading So when you inevitably run out of disk space and need to move things around, it’s a lot less stressful. And, once Lightroom has generated the preview files, you can perform your edits on them without access to the originals.
  • For professional photographers, it’s easy to setup separate catalogues for different client projects.
  • Excellent keyboard shortcuts – of which some of my favourites: Q to toggle in and out of Spot Removal, and [ and ] to vary the size of the brush. Holding down spacebar to switch between spot removal (or whatever else you’re doing) and the ability to move around the image. Z to toggle between two customisable zoom levels. \ to toggle between the original “before” image and your working version.
  • I don’t use HDR the often, but it’s a better implementation than anything else I’ve tried. Lightroom just doesn’t do a ‘dramatic’ setting (which imho looks hugely unrealistic – now some people really do like that sort of style, but I like to imagine they’re the same people who are into emoji and memes…) Also though, if there isn’t enough in common between the images – i.e. something has moved – it’ll simply refuse to merge them, rather than do a mediocre job.
  • Similarly, Spot removal is simply much higher quality than other apps I’ve tried (e.g. Pixelmator Pro, Serif Affinity Photo[5]though it’s very nice to see Serif making something popular again, as someone who loved PagePlus back in the 90s. Tips: if you get a blurry mess, try making the brush a bit larger. Also remember to use the H shortcut to show where it’s cloned the replacement from, which you can then drag around if lines don’t match up. It’s very quick too – this photo includes, oh I don’t know, 50+ instances of spot removal to clear large amounts of guano and chewing gum off Canterbury’s unloved paving stones? Yet I was able to do that in a few minutes on a nine-year-old Mac Mini (the previously mentioned hold-the-spacebar trick helps too).
  • I love the Flickr integration. The Flickr API hasn’t changed much on the surface (it’s a nearly twenty year-old legacy codebase), but the uploading support is solid, and being able to use all your existing keywords and metadata without having to enter it again, and merely dragging the image into the Flickr folder and clicking Publish is wonderful.
  • A side benefit: if Flickr ever did shut down for good, I already have a folder of everything I’ve published in the database, so it would be easy to move it somewhere else (and Lightroom includes a fairly sophisticated HTML gallery builder in the Web module, so you don’t need to make something by hand or rely on 3rd-party services).
  • Lightroom replicates the Fuji film simulations (Astia, Vevia, Classic Chrome etc. the various Acros monochrome versions…) very nicely. It’s not identical to Fuji’s own extraordinary technique, but you can regenerate JPEGs or TIFFs with your chosen film directly on the camera later using the RAW files if you prefer[6]and indeed you need to do that if you want to send the photos to a smartphone, because the Fuji Cam Remote app – 602 reviews and a measly average 1.4 out of 5 on the App Store that’s … Continue reading, however I’m not good enough to spot the difference between Adobe and Fuji’s work.
  • Martin Belam recently wrote about object selection in Photoshop. I’ve not been using Photoshop much lately, however there are a couple of similar features that have recently made it into Lightroom, which are astounding; specifically Select Subject and Select Sky. These take at most, 5+ seconds to run – again, this is on a computer that’s close to a decade old now – and providing your subject is relatively big, Select Subject is very accurate, regardless what said subject is (it correctly picked out a squirrel and the tree it was climbing for example, and will highlight multiple people in the frame, cyclists, people holding umbrellas etc etc.). You can of course modify the mask further, but for me it’s usually been spot on – and you can then invert it if you want to desaturate the background, for example. Colour Range is decent too, although it’s common to find the colour you’ve chosen in parts of the image you don’t want, so you should expect to use the refine slider or manually paint out areas you don’t want (when you’re using masks, remember the O shortcut to colour the mask red or green etc. so you can see the area that’ll be affected by it).
  • Another feature that’s maybe even more magical for me – the Transform panel. Because it means I can take a photo of a four-storey building from ground level, with all the inherent perspective, drag a couple of horizontal and vertical guides over it and Lightroom will magically straighten the whole thing out so it appears I shot it perfectly; dead centre, straight on, almost in mid-air. It does this by squashing the wider part of the photo and bringing in the area to the left or right, say, to fill the empty space, so you do need to leave some room around the edges of the frame otherwise your building will be cropped. But it’s a superb tool, which doesn’t appear to noticeably distort or otherwise harm humans or animals; the end result; more professional looking images with nice straight lines with, again, minimal effort.
  • Finally, exactly what happens should you ever stop paying your Adobe Creative Cloud subscription? Well, you can use everything except the Develop and Map modules – i.e. you can still access, search, sort, export, print and manage the metadata of photos, just not perform edits.

So in summary, Lightroom: some amazing maths tricks and the workflow and UX is amazing – even if it does eat RAM and freeze occasionally, it very much feels like it’s been battle tested by generations of photographers.


  • If you want to learn Lightroom, I’d suggest doing what I did and watching a few hours of the official tutorial videos before you even open it for the first time. It’ll help you understand what the hell is going on.
  • You don’t need to learn everything at once. e.g. I’m still at a stage where I have little understanding how the Tone Curve works (I’m privately convinced a lot of other people who’ve done tutorials about it don’t fully get it themselves either). I just use the Color panel and adjust the tint through trial and error.
  • Don’t waste your money on buying other people’s presets. Just learn a bit of the app at the time, and shoot in RAW so you can come back and re-edit in the future.
  • For the record, I’ve never once used the new Lightroom CC version.


1 Although, as it happens, you really don’t want to run them both at the same time as they hog so much memory…
2 That’s right, Flickr is still a thing. It also obeys my I’m-not-going-to-explain-this-very-clearly-am-I? theory of online communities – notably that they’re friendliest and most encouraging where they remain sufficiently narrowly focused on the population actively developing experience in a learning a particular Thing; everyone therefore appreciates the dedication, difficulty and frustration of doing the Thing even moderately well, and realises they’re probably not personally the best at it, so they can’t help but be supportive of the Thing(s) others may have created, and use them for inspiration. The lack of “influencers”, and people using it as somewhere to paste all their screenshots or indiscriminately backup every photo they ever took, as in the early years, probably helps considerably too.
3 I should add I’ve not tried Capture One, which lots of people like
4 Another reason not to use Apple Photos is how it insists on running an AI scan of your entire library which it’s impossible to switch off – although, small tip, opening the Photos app itself will pause the background process doing that, if all the fan noise is annoying you.
5 though it’s very nice to see Serif making something popular again, as someone who loved PagePlus back in the 90s
6 and indeed you need to do that if you want to send the photos to a smartphone, because the Fuji Cam Remote app – 602 reviews and a measly average 1.4 out of 5 on the App Store that’s entirely deserved due to the highly confusing and unreliable nature of the initial connection – won’t let you copy RAW files into an iCloud folder, it only works with the Apple Photos app

Software to avoid: ExpanDrive

Expandrive is a program that lets you mount external connections (SSH servers, Google Drive etc.) as volumes on a Mac, so you can drag/drop/save/load as if they were local.

Both the old version I had (6.4.7) and the newest release of version 7 essentially won’t connect to anything at all for me – either servers I run myself or Google Drive/Dropbox (in the case of the last two they get stuck in an infinite loop.)

This is on Mac running macOS Mojave 10.14.6.

There are log files, but they weren’t massively useful.

Didn’t get far with their live support. Similar complaints on Trustpilot. I believe it’s quite a small team (though more than one). Their apps are still actively developed, but if one doesn’t work and they can’t help you…

I asked if they operated a test server, which would be useful for diagnosing problems as they could use it to check the logs at their end. But they don’t.

Possibly the thing to get instead if you really need it is Transmit ($45), though I have gone back to moving files via the command line.

You accidentally deleted your entire Apple Photos library. How to undelete it.

e.g. you’re trying to view the package contents of the “Photos Library” (in /Users/[username]/Pictures/), so you can check an original file, RAW image, etc. – but you’re not thinking properly, accidentally click the wrong option in the menu and send the entire contents to the Recycle Bin by mistake.

You stop the deletion immediately, and the Photo Library isn’t in the Recycle Bin, and still appears to be in the usual location in the Finder, but, on launching Photos (macOS Mojave 10.14.6, in this case) it says it has failed to repair the library and invites you to open another one.

The fix is very simple – first, disconnect your Time Machine drive (or any other automated backup location) to avoid harming your backups.

  • close Photos if it’s open
  • hold down the command + option (alt) keys while clicking the icon
  • the Photos app will open and should immediately offer to repair the library for you.
  • supply password when prompted
  • wait a while (a few minutes for 80GB of photos in my case) while the photolibraryd process rebuilds the library (you’ll see a fairly accurate progress meter)
  • browse / continue to use the library for a while to check everything is still there and ok (mine was).

On a related note, I highly recommend Adobe Lightroom Classic (superbly well thought out app, very powerful and perhaps also the best designed keyboard shortcuts I have ever seen). The £10 a month Creative Cloud subscription is worth it (get the one that also gives you Photoshop). It’s considerably better at things like HDR and spot removal/healing brushes than, for example, Pixelmator Pro, Affinity Photo etc.

Only issue is that it can eat memory. Keep an eye on that and be prepared to relaunch if it, as has happened to me a couple of times, it creeps up to 9GB.

The WordPress Gutenberg block editor – a FAQ for cynics

Is it any good?

Meh. But I’ve reached the stage where I’ll no longer disable it by default.

Will it save you any time?

That depends on who “you” are and what you’re doing / writing. There are keyboard shortcuts (if you post often enough to memorise them), but you’ll probably find yourself using the mouse a lot more.

You’ll need to relearn where some things are in the sidebar (e.g. permalink settings) – and it doesn’t quite have feature parity there yet (unless I’m mistaken).

It’s certainly more useful friendly and (imho) also better having a toolbar and menus that adapt to the context.

The editor writing area is also incredibly uncluttered, though much of the stuff has been shoved in the (fixed width) sidebar that’s now full of sections you’ll need to learn to navigate or expand or collapse as needed, and also of course every other page in the WordPress admin area is exactly how it’s always been.

I’d describe it as stable – I’ve not had any real javascript errors yet.

What happens with old and new posts?

New posts

Once you disable the Classic Editor plugin, when you begin every new post you’ll start in the block editor.

Old posts

  • Crucially, turning on Gutenberg (by disabling the Classic Editor plugin) doesn’t make any difference to existing posts (created pre-Gutenberg, in TinyMCE) until you edit them.
  • When you do edit an old post, you get the new “minimalist” view, but your post is converted to a single “classic block” in “classic edit” mode. Once you place the cursor somewhere, you’ll see the familiar TinyMCE toolbar with font styles, buttons to add remove links and so on.

You can leave that intact and make simple edits, or add other blocks around it, or use the “convert to blocks” button, which splits a classic block up by paragraphs (and with some “intelligent” stuff based on the content.)

Classic Blocks also give you an ‘Edit as HTML’ option.

Here’s a slightly longer guide to avoid repeating what others have written.

What happens if you decide to turn Classic Editor back on for some reason?

Any posts you’ve written in the block editor would still display correctly: the code that renders Gutenberg blocks is in WordPress core. You can still edit them too, but you won’t see the new interface and you should switch to text mode – then you can see the HTML comment tags (because that’s how it works) used by the block editor to mark the start and end of blocks, and any extra metadata such as block titles.

All these HTML comment tags are only stored in the “posts” database table, they’re never sent to a user’s web browser. (The overall output seems just as clean as before.)

Converting blocks from one type to another

You’ll want to do this quite often. To change a block type, you click it’s icon (on the far left of the toolbar) – each block type has a different icon – e.g. the paragraph marker for a paragraph block, or a bookmark-style thing for headings.

There are limits on which block types you can convert between, some of which seem unnecessarily restrictive.


Shortcodes are still supported, but you need to paste them into a Shortcode block.

The “custom HTML” block type

Two key differences from Classic blocks:

  • HTML blocks don’t mess around with your code, adding
    or tags with every line break the way the old WordPress editor used to.
  • in HTML blocks, you can toggle between source and preview instantly without having to open a separate tab.

This would be the one to use for newsletters.

Reusable blocks

Key thing to remember: these aren’t empty templates you fill in each time – i.e. you can obviously reuse them across multiple posts, but editing a reusable block changes every instance of it across the site.

Also once you create them, unhelpfully they’re always labelled ‘Untitled’. You need to go to the Block Manager page (you can get to this via the … dropdown menu on the far-right when editing, under Tools > Manage all reusable blocks)

Detailed guide to reusable blocks

Shifting blocks around

Note you can shade several blocks in using the keyboard and the icon changes to a ‘stack’, you can then move them together using the up/down icons.

Block patterns

Frankly of very limited use right now.

A block pattern is a collection of predefined blocks and they are inserted all at once. (Add a block, choose ‘Patterns’ and use the dropdown menu to select the type you want.)

There isn’t really a way to configure your own patterns via the UI (though someone has written a ‘Custom block patterns’ plugin).

It’s possible to generate them by writing/updating a theme or plugin.

Compatibility with ‘Post templates’ plugin

(because I have a client who uses this). It’s a plugin that’s no longer updated so is not Gutenberg compatible.

You can still create new posts using post templates (i.e. go to Templates and choose ‘New post fromtemplate’).

When you do, it will appear as a single “classic block” and you will need to edit it manually.

Display – meta panels underneath the editor

(You may want to reduce clutter)

There’s a setting to show hide/all these individually, but it’s buried several menus deep.

  • Create or edit a post
  • Click on the three dot icon on the far right
  • then Preferences at the very bottom
  • then the Panels lh-menu item on the modal window that appears
  • then under ‘Additional’ you can show/hide all the sections (hiding things doesn’t get rid of any of the old settings)