Description
I know I can already change the default home directory of phive via command line option:
https://github.com/phar-io/phive/blob/master/src/shared/config/Config.php#L34-L39
But this is a bit cumbersome and error prone like I would loose all cached phars if I forget it in one command or just add a typo.
It would be convenient if I could change this via an environment variable like PHIVE_HOME
. The implementation could look like this:
public function getHomeDirectory(): Directory {
if ($this->cliOptions->hasOption('home')) {
$dir = new Directory($this->cliOptions->getOption('home'));
$dir->ensureExists();
return $dir;
}
if(false !== getenv('PHIVE_HOME')) {
$dir = new Directory(getenv('PHIVE_HOME'));
$dir->ensureExists();
return $dir;
}
$dir = $this->environment->getHomeDirectory()->child('.phive');
$dir->ensureExists();
return $dir;
}
Background is that I am working with a CI environment that does not cache files in ${HOME}
but only in ${HOME}/cache
so I could speed up the build process when I could set PHIVE_HOME=${HOME}/cache/.phive
. I do the same with GNUPGHOME
and several other tools. If you agree on that I'd be happy to provide a PR including unit tests of course.