Improve support for XDG and default to XDG config dir if both that and ~/.composer are available, fixes #9045
parent
92ef439666
commit
10590dc519
|
@ -5,6 +5,7 @@
|
||||||
- The new platform-check feature means that Composer checks the runtime PHP version and available extensions to ensure they match the project dependencies. If a mismatch is found, it exits with error details to make sure problems are not overlooked. To avoid issues when deploying to production it is recommended to run `composer check-platform-reqs` with the production PHP process as part of your build or deployment process.
|
- The new platform-check feature means that Composer checks the runtime PHP version and available extensions to ensure they match the project dependencies. If a mismatch is found, it exits with error details to make sure problems are not overlooked. To avoid issues when deploying to production it is recommended to run `composer check-platform-reqs` with the production PHP process as part of your build or deployment process.
|
||||||
- If a package exists in a higher priority repository, it will now be entirely ignored in lower priority repositories. See [repository priorities](https://getcomposer.org/repoprio) for details.
|
- If a package exists in a higher priority repository, it will now be entirely ignored in lower priority repositories. See [repository priorities](https://getcomposer.org/repoprio) for details.
|
||||||
- Invalid PSR-0 / PSR-4 class configurations will not autoload anymore in optimized-autoloader mode, as per the warnings introduced in 1.10
|
- Invalid PSR-0 / PSR-4 class configurations will not autoload anymore in optimized-autoloader mode, as per the warnings introduced in 1.10
|
||||||
|
- On linux systems supporting the XDG Base Directory Specification, Composer will now prefer using XDG_CONFIG_DIR/composer over ~/.composer if both are available (1.x used ~/.composer first)
|
||||||
- Package names now must comply to our [naming guidelines](doc/04-schema.md#name) or Composer will abort, as per the warnings introduced in 1.8.1
|
- Package names now must comply to our [naming guidelines](doc/04-schema.md#name) or Composer will abort, as per the warnings introduced in 1.8.1
|
||||||
- Deprecated --no-suggest flag as it is not needed anymore
|
- Deprecated --no-suggest flag as it is not needed anymore
|
||||||
- PEAR support (repository, downloader, etc.) has been removed
|
- PEAR support (repository, downloader, etc.) has been removed
|
||||||
|
|
|
@ -69,18 +69,32 @@ class Factory
|
||||||
}
|
}
|
||||||
|
|
||||||
$userDir = self::getUserDir();
|
$userDir = self::getUserDir();
|
||||||
if (is_dir($userDir . '/.composer')) {
|
$dirs = array();
|
||||||
return $userDir . '/.composer';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self::useXdg()) {
|
if (self::useXdg()) {
|
||||||
// XDG Base Directory Specifications
|
// XDG Base Directory Specifications
|
||||||
$xdgConfig = getenv('XDG_CONFIG_HOME') ?: $userDir . '/.config';
|
$xdgConfig = getenv('XDG_CONFIG_HOME');
|
||||||
|
if (!$xdgConfig && is_dir('/etc/xdg')) {
|
||||||
return $xdgConfig . '/composer';
|
$xdgConfig = '/etc/xdg';
|
||||||
|
}
|
||||||
|
if (!$xdgConfig) {
|
||||||
|
$xdgConfig = $userDir . '/.config';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $userDir . '/.composer';
|
$dirs[] = $xdgConfig . '/composer';
|
||||||
|
}
|
||||||
|
|
||||||
|
$dirs[] = $userDir . '/.composer';
|
||||||
|
|
||||||
|
// select first dir which exists of: $XDG_CONFIG_HOME/composer or ~/.composer
|
||||||
|
foreach ($dirs as $dir) {
|
||||||
|
if (is_dir($dir)) {
|
||||||
|
return $dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if none exists, we default to first defined one (XDG one if system uses it, or ~/.composer otherwise)
|
||||||
|
return $dirs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -644,6 +658,10 @@ class Factory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_dir('/etc/xdg')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue