-
Notifications
You must be signed in to change notification settings - Fork 318
CLI options
PsySH supports several command line flags to control its behavior when starting a shell session.
| Option | Description |
|---|---|
|
|
Display help message showing available options and usage. |
|
|
Use an alternate PsySH config file location. Example: psysh --config /path/to/custom-config.phpYou can also set the |
|
|
Use an alternate working directory. PsySH will start in this directory and look for a local Example: psysh --cwd /path/to/project |
|
|
Display the PsySH version number. |
|
|
Install a newer version if available. Only works when PsySH is installed as a PHAR. |
|
|
Download and install the latest PHP manual. Preserves the currently selected language. Example: psysh --update-manual
psysh --update-manual=fr # Switch language |
|
|
Force colors in output, even if color support isn't detected. |
|
|
Disable colors in output, even if the terminal supports them. |
|
|
Alias for |
|
|
Alias for |
|
|
Run with compact output (less whitespace). This is the same as using the Example: psysh --compact |
|
|
Quiet mode. Suppresses most output except for evaluation results and errors. |
|
|
Increase the verbosity of messages:
Example: psysh -vvv # Debug mode |
|
|
Print Example: echo '<?php return [1, 2, 3];' | psysh --raw-output |
|
|
Force interactive mode, even if PsySH detects that input is coming from a pipe or non-interactive source. |
|
|
Force non-interactive mode. PsySH will read input from stdin and execute it without starting an interactive shell. Requires input from stdin. Example: echo '<?php echo "Hello";' | psysh --no-interactive |
|
|
Alias for |
|
|
Alias for |
|
|
Enable autoload warming to pre-load classes for better tab completion and command support. When enabled, PsySH will scan your project's Composer autoloader at startup to discover available classes. This makes classes available to tab completion and commands like Example: psysh --warm-autoloadFor fine-grained control, use the [[ |
|
|
Run PsySH with minimal input validation. This disables the CodeCleaner validation passes. You probably don't want this. It can lead to confusing errors and unexpected behavior. This option exists mainly for debugging PsySH itself. |
psysh --color --compactecho '<?php echo "Hello World";' | psysh --no-interactivepsysh --config /path/to/config.php --warm-autoloadpsysh -vvv --colorpsysh < script.phpecho '<?php return 42;' | psysh --quiet --raw-outputCommand line options override configuration file settings. For example:
# This will use compact output even if your config.php sets compact to false
psysh --compactPsySH respects several environment variables to control its behavior and locate configuration files.
-
PSYSH_CONFIG- Path to config file (same as--config) -
PSYSH_IGNORE_ENV- Set to1to bypass PHP version and extension checks (use with caution)
Examples:
# Use custom config file
export PSYSH_CONFIG=/path/to/config.php
psysh
# Override version/extension checks (not recommended)
export PSYSH_IGNORE_ENV=1
psysh-
TERM- Terminal type (PsySH disables colors if set todumb)
PsySH follows the XDG Base Directory Specification for locating configuration and data files on Unix-like systems.
-
XDG_CONFIG_HOME- Base directory for config files (default:~/.config) -
XDG_CONFIG_DIRS- Additional config directories (default:/etc/xdg) -
XDG_DATA_HOME- Base directory for data files (default:~/.local/share) -
XDG_DATA_DIRS- Additional data directories (default:/usr/local/share:/usr/share) -
XDG_RUNTIME_DIR- Base directory for runtime files (default: system temp dir)
Examples:
# Custom XDG directories
export XDG_CONFIG_HOME=~/my-config
export XDG_DATA_HOME=~/my-data
# PsySH will look for config at ~/my-config/psysh/config.php
# and store history at ~/my-data/psysh/
psyshNote: On Windows, PsySH uses %APPDATA%\PsySH for both config and data instead of XDG paths.