From the command line, I can get the home directory like this:
~/
How can I get the home directory inside my PHP CLI script?
$_SERVER['HOME'] and getenv('home') did not work for me.
However, on PHP 5.5+, this worked to give the home directory that the file is located in:
explode( '/', __FILE__ )[2]