Posts about PHP
-
De-hybridize Torrent
A feature that may be desired for some anti-V2 trackers. While I would like to see the torrent community going the other way around, some trackers choose not to allow version 2 torrents and sometimes even hybrids.
The torrent file library now allows cleaning unnecessary or undesired metadata versions from a torrent file.
The intended use and the primary future scope is actually the other way around: the ability to remove version 1 metadata to make use of easy mutability of version 2 torrents to add or remove files in existing torrent structures.
-
PHP Requirements on Packagist
A followup for the previous post: the minimum required PHP versions in packages on the Packagist.
-
How to Choose a Minimum PHP Requirement
As a library developer I often face a problem what should be a minimum PHP requirement. Here are some of my principles.
-
UUID Library (and ULID to UUID migration)
I created a UUID and ULID library with Doctrine support. Well, who didn't :D
The main scenario for myself was a possible migration for a project from ULIDs to UUIDs since UUIDs got a little bit of support in MySQL 8.
Example code:
<?php use Arokettu\Uuid\UuidParser; // Just a random ULID $ulid = UuidParser::fromBase32('01H44RDYXJPFCF895N3BBXCZRC'); var_dump($ulid->isUuidV7Compatible()); // false // UnexpectedValueException: This ULID cannot be converted to UUID v7 losslessly // $uuid = $ulid->toUuidV7(); $uuid = $ulid->toUuidV7(lossy: true); // note digit 13 becoming '7' and digit 17 moving into [89ab] range var_dump($uuid->toString()); // 01890986-fbb2-73d8-b424-b51ad7d67f0c var_dump($ulid->toRfc4122()); // 01890986-fbb2-b3d8-f424-b51ad7d67f0c var_dump($uuid->toBase32()); // 01H44RDYXJEFCB895N3BBXCZRC var_dump($ulid->toString()); // 01H44RDYXJPFCF895N3BBXCZRC
-
March Packages on Packagist
I'm continuing to publish useless nih junk on the Packagist:
arokettu/arithmetic-parser: A very configurable arithmetic parser and calculator. You can define your own set of functions and operators. You can even disable multiplication if you want to!
arokettu/clock: A set of PSR-20 clock implementations. Everyone has these implemented so why not me? :D
arokettu/system-clock: All these PSR-20 clock packages usually contain a ton of clocks for testing purposes but most of the production code needs only
new DateTimeImmutable('now')
so I extracted SystemClock to a separate package that has only SystemClock.php and composer.json for the smallest possible package (if you don't count uglifying it js-like)-
arokettu/kilo-mega: This one was actually released on February but I've forgot to write about it. It's a simple formatter for metric prefixes.
Also a new significant release:
arokettu/torrent-file: Torrent file class got file listing classes for v1 and v2 metadata in 5.0 release.
-
Moving packages to Arokettu
Just finished moving my old composer packages from
sandfoxme/*
toarokettu/*
.Full list:
I tried to make the migration process as smooth as possible. I'm sorry for the inconvenience it might have caused.
-
Installing Composer in Docker the 2020-s Way
While the original way is still valid, in Docker it's now easier to copy the Composer executable from its Docker image.
or for PHP < 7.2.5
Please note that without the installer, dependencies won't be checked, so you also need to install git and/or zip, and preferably optional dependencies like mbstring too.
Found accidentally on the Stack Overflow. There is also another interesting and underliked method for the case when you don't want to keep the composer executable and cache files in your image.
-
OpenSpout
I have recently found myself in a situation when 3 out of 4 libraries that I used to work with Excel files were abandoned:
akeneo-labs/spreadsheet-parser (streaming reader) had no commits in 4 years
mk-j/php_xlsxwriter (streaming writer) had no commits in 2 years
box/spout (streaming reader/writer) is formally abandoned
Luckily there exists a community fork of Spout called OpenSpout and it can replace them all. It seems pretty popular with 1 mln downloads and 229 stars but it's still less popular than the original and I managed to find it only by navigating the forks of Spout so I think it just needs more exposure.
-
PHP 8.2 and my achievement
A small step for the community may still be a huge leap for specific people, like Pierrick Charron and Sergey Panteleev who became this version release managers. I would like to congratulate them with a successful release.
This moon-in-reverse scale leap also happened to me: I got my first MR accepted to the PHP itself. It's the second C-based project that I contributed professionally, and the only huge one. The first one was my systemd-journal lib wrapper.
-
PHP 8.2 and my libraries
I have re-tested all my libraries for compatibility with PHP 8.2. Luckily due to small amount of changes and, well, me not using some bad practices, they are all compatible with the new release.
Only MonsterID had a new release to leverage the new Random Extension.