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

Breadcrumb

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

function Platform::getUserDirectory

Return value

string The formal user home as detected from environment parameters

Throws

\RuntimeException If the user home could not reliably be determined

1 call to Platform::getUserDirectory()
Platform::expandPath in vendor/composer/composer/src/Composer/Util/Platform.php
Parses tildes and environment variables in paths.

File

vendor/composer/composer/src/Composer/Util/Platform.php, line 133

Class

Platform
Platform helper for uniform platform-specific tests.

Namespace

Composer\Util

Code

public static function getUserDirectory() : string {
    if (false !== ($home = self::getEnv('HOME'))) {
        return $home;
    }
    if (self::isWindows() && false !== ($home = self::getEnv('USERPROFILE'))) {
        return $home;
    }
    if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
        $info = posix_getpwuid(posix_getuid());
        if (is_array($info)) {
            return $info['dir'];
        }
    }
    throw new \RuntimeException('Could not determine user directory');
}

API Navigation

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