Install direnv:

sudo pacman -S direnv

Create PHP binaries

Example :

$ cd ~
$ mkdir bin/php82 && cd bin/php82 && ln -s /usr/bin/php82 ./php
$ mkdir bin/php83 && cd bin/php83 && ln -s /usr/bin/php ./php
$ cd [project]
$ echo 'export PATH=/home/jchatard/bin/php82:$PATH' > .envrc
$ direnv allow
$ php --version
PHP 8.2.26 (cli) (built: Jan  7 2025 14:03:55) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.26, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.26, Copyright (c), by Zend Technologies
    with Xdebug v3.4.0, Copyright (c) 2002-2024, by Derick Rethans