Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Path.php

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\Filesystem

Code

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.");
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal