New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: XDG Base Directory for .php_history #8546
Comments
iluuu1994
added
Extension: readline
Status: Verified
and removed
Status: Needs Triage
labels
May 20, 2022
paulfedorow
added a commit
to paulfedorow/php-src
that referenced
this issue
Nov 1, 2023
Resolves phpGH-8546. To keep existing installations working the code first checks if a history file already exists at `~/.php_history`. If it does, then everything works as before. If `~/.php_history` does not exist, we check whether the system supports the XDG Base Directory Specification. If it doesn't we continue using `~/.php_history`; otherwise, we use a path that conforms to the XDG Base Directory Specification. We detect support for XDG Base Directory Specification by checking for environment variables that start with the `XDG_` prefix. This is analogous to what Composer does: composer/composer#1407 The specification can be found here: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
paulfedorow
added a commit
to paulfedorow/php-src
that referenced
this issue
Nov 1, 2023
Resolves phpGH-8546. To keep existing installations working the code first checks if a history file already exists at `~/.php_history`. If it does, then everything works as before. If `~/.php_history` does not exist, we check whether the system supports the XDG Base Directory Specification. If it doesn't we continue using `~/.php_history`; otherwise, we use a path that conforms to the XDG Base Directory Specification. We detect support for XDG Base Directory Specification by checking for environment variables that start with the `XDG_` prefix. This is analogous to what Composer does: composer/composer#1407 The specification can be found here: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Why is this not being defined as an environment variable with a default fallback? Other languages use such a lookup strategy (see 2 examples below):
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
There are several ways to support XDG Base Directory:
.php_history
to$XDG_DATA_HOME/php/history
. If$XDG_DATA_HOME
is not defined, use$HOME/.local/share
instead..php_history
to$XDG_DATA_HOME/php/history
only if$XDG_DATA_HOME
is defined. If not, use$HOME/.php_history
as before.$PHP_HISTFILE
. If$PHP_HISTFILE
is not set, use$HOME/.php_history
as before.The text was updated successfully, but these errors were encountered: