-
Couldn't load subscription status.
- Fork 8k
Closed
Description
Description
XDG Base Directory is a specification that defines a list of directories where applications should store configs/data/caches. It is not required to follow, but many applications support it today.
For PHP, the location of .php_history, a file storing command line history in the REPL (php -a), is fixed to home directory.
ext/readline/readline_cli.c:
#ifndef PHP_WIN32
history_file = tilde_expand("~/.php_history");
#else
spprintf(&history_file, MAX_PATH, "%s/.php_history", getenv("USERPROFILE"));
#endifThere are several ways to support XDG Base Directory:
- Change path of
.php_historyto$XDG_DATA_HOME/php/history. If$XDG_DATA_HOMEis not defined, use$HOME/.local/shareinstead. - Change default path of
.php_historyto$XDG_DATA_HOME/php/historyonly if$XDG_DATA_HOMEis defined. If not, use$HOME/.php_historyas before. - Introduce a new environment variable to set history file path like
$PHP_HISTFILE. If$PHP_HISTFILEis not set, use$HOME/.php_historyas before.
fengtan and januz