PHP has recently added support for AVIF in version 8.1. To this date, no native PHP support is available. Luckily, Johannes Siipola has created a PHP library for encoding JPEG XL images. It requires PHP 7.2.5 or later and works under Linux, macOS, or Windows OS with x64 architecture. Check out the plugin and the installation guide right on his Github page.