@abulhol This is really weird. I just cannot replicate the issue for the heck of it.
but it doesn’t find php this way, probably because at this point a full shell isn’t available yet (?).
Probably right. Looks like environment.d is systemd’s part to generate the environment. I am trying to figure out how to analyze this. So I am just throwing a few commands at you and we’ll see what we find. Please run the same commands on your system and compare the outputs:
root@ubuntu2204-fog:~# systemd-analyze critical-chain
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.
graphical.target @19.463s
└─multi-user.target @19.460s
└─FOGSnapinReplicator.service @19.447s
└─mariadb.service @17.581s +1.755s
└─basic.target @17.468s
└─sockets.target @17.468s
└─snapd.socket @17.428s +33ms
└─sysinit.target @17.397s
└─cloud-init.service @16.654s +738ms
└─systemd-networkd-wait-online.service @3.060s +13.592s
└─systemd-networkd.service @2.966s +92ms
└─network-pre.target @2.960s
└─cloud-init-local.service @1.075s +1.883s
└─systemd-remount-fs.service @952ms +99ms
└─systemd-journald.socket @658ms
└─system.slice @615ms
└─-.slice @615ms
root@ubuntu2204-fog:~# systemd-analyze blame | head
13.592s systemd-networkd-wait-online.service
2.483s dev-sda2.device
1.883s cloud-init-local.service
1.778s cloud-config.service
1.755s mariadb.service
1.029s cloud-final.service
879ms networkd-dispatcher.service
874ms snapd.service
791ms php8.1-fpm.service
777ms systemd-random-seed.service
root@ubuntu2204-fog:~# systemd-analyze plot >systemd-plot.svg
Now copy that SVG file to another system where you have a UI and open it (e.g. using the Linux tool eog - here is how mine looks like (not the whole lot because that’s too big to upload here):

root@ubuntu2204-fog:~# systemd-analyze dot 'FOG*' |dot -Tsvg > systemd-dot.svg

root@ubuntu2204-fog:~# ls -al $(which php)
lrwxrwxrwx 1 root root 21 Feb 22 13:24 /usr/bin/php -> /etc/alternatives/php
root@ubuntu2204-fog:~# ls -al /etc/alternatives/php
lrwxrwxrwx 1 root root 20 Feb 22 13:26 /etc/alternatives/php -> /usr/bin/php.default
root@ubuntu2204-fog:~# ls -al /usr/bin/php.default
lrwxrwxrwx 1 root root 6 Jan 28 2022 /usr/bin/php.default -> php8.1
root@ubuntu2204-fog:~# ls -al /usr/bin/php8.1
-rwxr-xr-x 1 root root 5531064 Jan 16 15:19 /usr/bin/php8.1