From the command line, I can get the home directory like this:
~/
How can I get the home directory inside my PHP CLI script?
Try $_SERVER['DOCUMENT_ROOT'] as your home directory.
$_SERVER['DOCUMENT_ROOT']