Skip to content

Feature request: XDG Base Directory for .php_history #8546

Closed
@nsfisis

Description

@nsfisis

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"));
#endif

There are several ways to support XDG Base Directory:

  • Change path of .php_history to $XDG_DATA_HOME/php/history. If $XDG_DATA_HOME is not defined, use $HOME/.local/share instead.
  • Change default path of .php_history to $XDG_DATA_HOME/php/history only if $XDG_DATA_HOME is defined. If not, use $HOME/.php_history as before.
  • Introduce a new environment variable to set history file path like $PHP_HISTFILE. If $PHP_HISTFILE is not set, use $HOME/.php_history as before.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions