The web and command line PHP versions can be different on some hosting. If the hosting is managed, there's usually a PHP version choice somewhere that applies globally to the command line, which can be different from each individual site PHP version. Ideally both should be identical to use Flarum.
If the hosting isn't managed and there are multiple PHP versions, there's a command to update which one the php
alias points to, though I don't remember it. You can also manually call the PHP executable you need if the default cannot be changed, for example php8.0 composer install [...]
. The exact name of the PHP executable for each version might vary depending on the operating system.