How to switch to another version of php in the terminal (terminal) and opr site beget


In the terminal, you may display a different php version with the command php -v . In some projects (for example, symfony as a composer), you have to execute commands but you need to change the version, in order to change the version we will do several commands in the terminal:
whereis php - see the list of available symbolic links (links to php versions)
which php - see the currently executing symbolic link (php version link)
alias php="/usr/local/bin/php7.2" - using the "alias" command we change / or add (if not) the current symlink (php version) selected from the list
php -v - see the version you switched to
After we understood how to change the php version in beget, now we create a file in the root of your site .bashrc
This is done so that when connecting to the server, you do not have to constantly change the version.
Next, write the command in the file: alias php="/usr/local/bin/php7.2"

If you had problems cleaning up a symfony project and needed to change the version, you can now clean up the cache:
- php bin/console cache:clear