You must use a tool like phpswitch (https://github.com/jubianchi/phpswitch) or php-build (https://github.com/CHH/php-build).

They are awesome to manage multiple PHP version on the same machine. It must be a developer machine but it seems to fit your needs…