function Path::getHomeDirectory
Returns canonical path of the user's home directory.
Supported operating systems:
- UNIX
- Windows8 and upper
If your operating system or environment isn't supported, an exception is thrown.
The result is a canonical path.
Throws
RuntimeException If your operating system or environment isn't supported
1 call to Path::getHomeDirectory()
- Path::canonicalize in vendor/
symfony/ filesystem/ Path.php - Canonicalizes the given path.
File
-
vendor/
symfony/ filesystem/ Path.php, line 189
Class
- Path
- Contains utility methods for handling path strings.
Namespace
Symfony\Component\FilesystemCode
public static function getHomeDirectory() : string {
// For UNIX support
if (getenv('HOME')) {
return self::canonicalize(getenv('HOME'));
}
// For >= Windows8 support
if (getenv('HOMEDRIVE') && getenv('HOMEPATH')) {
return self::canonicalize(getenv('HOMEDRIVE') . getenv('HOMEPATH'));
}
throw new RuntimeException("Cannot find the home directory path: Your environment or operating system isn't supported.");
}