Run composer with different php version

If your default php is 7.2 for ex. but your site is with php7.4-fpm, how to use the same php7.4 when using composer for managing the modules?
How to have multiple php?
How to use them?
Just in virtualhost config use as