ImagickException: unable to open file ‘/tmp/magick-…’ – Christian Weiske

I’m moving to a new server, and my avatar image generation script did not work anymore:

$ php surrogator.php
processing mm.svg
PHP Fatal error: Uncaught ImagickException: unable to open file `/tmp/magick-bcfNKPgxfBoOcZ5_de_xB9LzxZLhN2Dq': No such file or directory @ error/constitute.c/ReadImage/614 in /home/cweiske/www/avatar.cweiske.de/surrogator.php:236
Stack trace:
#0 /home/cweiske/www/avatar.cweiske.de/surrogator.php(236): Imagick->readImage()
#1 /home/cweiske/www/avatar.cweiske.de/surrogator.php(155): surrogator\createSquare()
#2 {main} thrown in /home/cweiske/www/avatar.cweiske.de/surrogator.php on line 236

The mm.svg file clearly exists, and my user is able to create files in /tmp/ – which I tested with touch /tmp/foo.

Using strace helped me to find the issue:

$ strace php surrogator.php
[...]
lstat("/usr/lib/x86_64-linux-gnu/ImageMagick-6.9.11/modules-Q16/coders/svg.la", 0x7ffd264c61c0) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
stat("/usr/lib/x86_64-linux-gnu/ImageMagick-6.9.11//modules-Q16/coders/svg.la", 0x7ffd264c61f0) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
stat("/tmp/magick-Uoh--TjgMhCveOq8LHbHQyVLXA87cpvx", 0x7ffd264ca2b0) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
stat("/home/cweiske/www/avatar.cweiske.de/raw/mm.svg", {st_mode=S_IFREG|0644, st_size=3013, ...}) = 0
write(2, "PHP Fatal error: Uncaught Imagi"..., 497PHP Fatal error: Uncaught ImagickException: unable to open file `/tmp/magick-Uoh--TjgMhCveOq8LHbHQyVLXA87cpvx': No such file or directory @ error/constitute.c/ReadImage/614 in /home/cweiske/www/avatar.cweiske.de/surrogator.php:236
[...]

PHP’s Imagick extension wants to load the svg.la module that is responsible for loading .svg images, and that fails.

It turned out that I had to install the imagemagick package – php-imagick alone was not enough.

Using PSR-3 placeholders properly – Larry Garfield

Using PSR-3 placeholders properly

In the last 2 years or so, I’ve run into a number of projects that claim to use the PSR-3 logging standard as published by the PHP Framework Interoperability Group (PHP-FIG, or just FIG). Unfortunately, it’s quite clear that those responsible for the project have not understood PSR-3 and how it is intended to work. This frustrates me greatly, as PSR-3’s design addresses a number of issues that these projects are not benefiting from, and it reduces interoperability between projects (which was the whole point in the first place).

Rather than just rant angrily online (fun as it is, it doesn’t actually accomplish anything), many of my PHP community colleagues encouraged me to blog about using PSR-3 properly. So, here we are.

Larry
26 February 2023 – 10:26am

PHPUK 2023 – Rob Allen

I have just returned from the 2023 edition of PHPUK and, as always, found it a valuable conference to catch up with the PHP community and find out what’s happening in the ecosystem.

This year, I was accepted to speak on the differences between RPC, REST and GraphQL APIs and was surprised and gratified that the room was at full capacity. Thank you to everyone that attended; I hope that you learnt something useful. I think that good APIs matter and am fairly pragmatic about implementations. In general, I would far rather that you wrote a really good RPC API than a bad GraphQL one for example.

The developer experience of an API matters, which is why it’s important that your API follows best practices for the architecture that you choose. For instance, follow the Relay pagination specification if you are writing a GraphQL API, or follow HTTP semantics and use status codes properly if you are writing a RESTful API. This stuff is key as developer word-of-mouth about how good your API is to use is valuable marketing.

The conference had many good talks. For instance Ian’s talk on PHP on Lambda provided valuable information and Pauline reprised her excellent talk on Git to fill the slot after a speaker pulled out. Pauline also spoke about the decentralised web, a talk I recommend that you seek out when the videos are published. All in all, the standard of talks was very high and I heard a good buzz about lots of them.

In our world of remote work, in an industry where interruptions are disruptive to the flow state that we get into when working, I can’t emphasise enough how useful the connections we make at in-person conferences can be. It’s a fantastic way to connect and talk about issues directly relevant to your work life and get other people’s thoughts with more context than is usually possible in other mediums.

The people I have met at conferences have materially affected my career for the better and I encourage everyone to try to attend a conference that’s relevant for their work at least per year.

Winding down Bad Gateway – Evert Pot

In 2019 I started Bad Gateway as a software development agency. Last year we
grew all the way to 7 people. It was crazy challenging, especially with Covid
in the mix; but ultimately could not get the company into a good financial
state to be able to carry on.

Big thanks to my co-workers and partners Ju, Becky, Phil,
Michael, Siep, Richard and Syed.
I’m incredibly grateful you came on this journey with me. We shared some
tears, exchanged some words but mostly had lots of laughs. Despite the
challenges I feel my relationship with you has only strengthened and I wish
you well in the next steps of your career.

Also thank you to our customers and especially Underknown who’ve stuck
with us since the start.

Despite this outcome, I have a hard time seeing the last few years as a
failure. It’s been hella fun, and I feel we stuck to our values even in times
of crisis. Off to the next adventure.

Image of person standing in front of a gateway.

Building a simple CLI tool with modern Node.js – Evert Pot

I’m a maintainer of several dozen open source libraries. One thing I’ve
always done is maintain a hand-written changelog.

Here’s an example from a12n-server

0.22.0 (2022-09-27)
-------------------

Warning note for upgraders. This release has a database migration on the
`oauth2_tokens` table. For most users this is the largest table, some
downtime may be expected while the server runs its migrations.

* #425: Using a `client_secret` is now supported with `authorization_code`, and it's read from either the request body or HTTP Basic Authorization header.
* The service now keeps track when issuing access tokens, whether those tokens have used a `client_secret` or not, which `grant_type` was used to issue them and what scopes were requested. This work is done to better support OAuth2 scopes in the future, and eventually OpenID Connect.
* Fixed broken 'principal uri' in introspection endpoint response.
* OAuth2 service is almost entirely rewritten.
* The number of tokens issued is now displayed on the home page.
* Large numbers are now abbreviated with `K` and `M`.
* #426: Updated to Curveball 0.20.
* #427: Typescript types for the database schema are now auto-generated with `mysql-types-generator`.

These are all written in Markdown. You might think: isn’t Git also a log? Why
bother hand-writing these?

The reason is that the audience for these is a bit different. I want to bring
attention to the things that are the most important for the end-user, and
focus on the impact of the change to the user.

I thought it would be handy to write a CLI tool that makes it a bit easier to
maintain these. So, I did!. If you are curious what kind of technology
choices went into this, read on.

Goals and features

The tool should be able to do the following:

  • Reformat changelogs (a bit like prettify) (changelog format)
  • Add an entry via the command line (changelog add --minor -m "New feature").
  • Automatically set the release date (changelog release)
  • Pipe a log of a specific version to STDOUT, so it can be used by other tools
    (like integrating with github releases).

I also had a bunch of a non-functional requirements:

  • Use the latest Node features.
  • Use up to date Javascript standards and features (ESM).
  • Avoid dependendencies unless it’s unreasonable to do so.
  • Make it low maintanance.

Want to find the finished tool right now? It’s open source so just go to Github.

The implementation

ESM & Typescript

Ecmascripts modules worked really well here. It’s a small change of habits,
but the general recommendation I would have is to just save your files
as .mjs and start using it.

Here’s the first few lines of parse.mjs:

// @ts-check
import { Changelog, VersionLog } from "./changelog.mjs";
import { readFile } from 'node:fs/promises'; /** * @param {string} filename * @returns {Promise<Changelog>} */
export async function parseFile(

Truncated by Planet PHP, read more at the original (another 27805 bytes)

Xdebug Update: January 2023 – Derick Rethans

Xdebug Update: January 2023

In this monthly update I explain what happened with Xdebug development in this past month. These are normally published on the first Tuesday on or after the 5th of each month.

Patreon and GitHub supporters will get it earlier, around the first of each month.

You can become a patron or support me through GitHub Sponsors. I am currently 41% (4% less than last month) towards my $2,500 per month goal. If you are leading a team or company, then it is also possible to support Xdebug through a subscription.

In the last month, I spend 18 hours on Xdebug, with 26 hours funded. Sponsorships, especially through Patreon, are continuing to decline, which makes it harder for me to dedicate time for maintenance and development.

Xdebug 3.2

I have continued to triage new bug reports in Xdebug 3.2, and most notably trying to find the bug that people reported with regards to the xdebug.mode setting not sticking, or being wrong. So far I have not managed to reproduce this in a reliable environment. If you run into this bug, please get in contact so that I can figure out what the cause is, by being able to reproduce this.

During a support call with one of my supporters, we discussed an issue that prevented correct breakpoints from being set through the PHP Debug Adapter for Visual Studio Code for virtual file systems, such as with the SSH FS plug-in. The debug adaptor did not know how to use a path mapping with this specific schema to work. There is now a new release (1.13.0) of the plug-in (https://marketplace.visualstudio.com/items/xdebug.php-debug/changelog) to make the following work:

"pathMappings": { "/home/derick/dev": "ssh://singlemalt/home/derick/dev"
}, 

Which maps the server path /home/derick/dev/ to the virtual file path ssh:://singlemalt/home/derick/dev, which I have added to my workspace.