From the command line, I can get the home directory like this:
~/
How can I get the home directory inside my PHP CLI script?
You can fetch the value of $HOME from the environment: