Pragmatism in the real world

Changing an SQL Server primary key in Doctrine Migrations

I recently came across a rather weird quirk when trying to change a primary key in Sql Server using Doctrine Migrations: you need to use two migrations to get it to work. This is incredibly minor and I'm only writing it up as it confused me for a while so I thought that I'd document so that I'll find this article if I run across it again in the future! This is the migration: final… continue reading.

First steps with Windows on Vagrant

One thing that would be useful for one of my projects is an easy way to install IIS, PHP & SQL Server on Windows in a repeatable way. I wasn't sure how to do this until I came across Chocolatey and Boxstarter. Chocolatey is a package manager for Windows along the same lines as yum and apt for Linux and knows how to install a remarkable amount of software. Boxstarter is a way to automate… continue reading.

Testing migrating to Laminas

Zend Framework is renaming to Laminas and all the source code is moving to a new GitHub organisation. Implicitly this means a new PHP top level namespace. As you can imagine, this implies that a lot of our code will need to change, so Matthew, Michał and the team have been writing migration tooling to make this easier. It's now time to test it and they need all the help they can get on real-world… continue reading.

Embedding Notist slides

This site uses WordPress under the hood as I find the flexibility that a good CMS provides quite useful. For the talks section, I use a custom post type so that I can set additional properties on the post and customise the display. With my usual lack of imagination, my custom post type is called talk. When Notist was released, I've been uploading the PDFs for my presentations there so that I have a nicely… continue reading.

HTML encode selected text on Mac

When writing blog posts, I write directly in HTML, mostly from habit and because I've not set up mark-up text processing on WordPress. I'm comfortable enough with simple HTML that it's never seemed important enough to sort out, especially with MarsEdit's macros for common HTML tags. One thing that I need to do relatively regularly is to HTML encode code snippets for use in <tt> and <pre> tags. I have been doing this via a… continue reading.

Custom error rendering in Slim 4

One of the nice things about Slim 4 is that it's easier to customise the HTML generated on error without having to worry about the rest of the error handling mechanism. This is because we have separated error rendering from error handling. Slim's default ErrorHandler maintains a list of renderers, one for each content-type and will delegate the creation of the error payload (HTML, JSON, XML, etc) to the renderer. Out of the Box, the… continue reading.

Folder types in AppleScript

I've recently moved to Adobe Lightroom Classic for photo editing, but am still using Apple Photos for viewing my photos on my iPhone and iPad. As such, I wanted an easy way to import photos exported from Lightroom into Photos, so I turned to AppleScript. My requirements are that I want to import all the photos in each sub-folder of a root folder called "ToPhotos" into Folders and Albums in Photos that are a child… continue reading.

Dependency Injection in Slim 4

In contrast with Slim 2 and Slim 3, Slim 4 does not ship with a DI container, but instead, supports any PSR-11 compatibly DI container that you provide. This is part of Slim 4's commitment to interoperability via the PHP-FIG standards. The easiest way to add a container to your Slim application is to call AppFactory::setContainer() before you call AppFactory::create(). The setContainer() method expects any PSR-11 container. Register the container with Slim Let's look at… continue reading.

Running Slim 4 in a subdirectory

If you want to run Slim 4 in a subdirectory of your website, then you have a few things you need to do. Let's consider the situation: Your main website is in the directory /var/www/html and is accessed at https://example.com/. You want your new Slim 4 app to be in the directory /var/www/html/myapp and to be accessed at https://example.com/myapp. Your Slim 4 index.php file is stored in /var/www/html/myapp. There are two things you need to… continue reading.

Slim4-empty: minimal Slim 4 starting point

To simplify creating a new Slim 4 project, I've created slim4-empty which does this for me. To use it: $ composer create-project akrabat/slim4-empty my-new-project and you're done! The my-new-project directory is created and contains Slim 4 along with a minimally viable public/index.php to get you going. You can then run it with the PHP built-in server: php -S 0.0.0.0:8888 -t public/ And navigate to https://localhost:8888 to view "Hello World" in your browser. What does it… continue reading.