Skip to content

CLI options

Justin Hileman edited this page Oct 27, 2025 · 3 revisions

⌨️ Command Line Options

PsySH supports several command line flags to control its behavior when starting a shell session.

Option Description

Basic Options

-h, --help

Display help message showing available options and usage.

-c, --config FILE

Use an alternate PsySH config file location.

Example:

psysh --config /path/to/custom-config.php

You can also set the PSYSH_CONFIG environment variable.

--cwd PATH

Use an alternate working directory. PsySH will start in this directory and look for a local .psysh.php config file there.

Example:

psysh --cwd /path/to/project

-V, --version

Display the PsySH version number.

-u, --self-update

Install a newer version if available. Only works when PsySH is installed as a PHAR.

--update-manual

Download and install the latest PHP manual. Preserves the currently selected language.

Example:

psysh --update-manual
psysh --update-manual=fr  # Switch language

Output Options

--color

Force colors in output, even if color support isn't detected.

--no-color

Disable colors in output, even if the terminal supports them.

--ansi

Alias for --color. Provided for compatibility with Symfony Console, Composer, and other tools.

--no-ansi

Alias for --no-color. Provided for compatibility with Symfony Console, Composer, and other tools.

--compact

Run with compact output (less whitespace). This is the same as using the compact theme option.

Example:

psysh --compact

-q, --quiet

Quiet mode. Suppresses most output except for evaluation results and errors.

-v, -vv, -vvv, --verbose

Increase the verbosity of messages:

  • -v - Verbose output
  • -vv - Very verbose output
  • -vvv - Debug output (maximum verbosity)

Example:

psysh -vvv  # Debug mode

-r, --raw-output

Print var_export-style return values instead of the pretty-printed output. This is particularly useful for non-interactive/piped input.

Example:

echo '<?php return [1, 2, 3];' | psysh --raw-output

Interactive Mode Options

-i, -a, --interactive

Force interactive mode, even if PsySH detects that input is coming from a pipe or non-interactive source.

-n, --no-interactive

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

--interaction

Alias for --interactive. Provided for compatibility with Symfony Console, Composer, and other tools.

--no-interaction

Alias for --no-interactive. Provided for compatibility with Symfony Console, Composer, and other tools.

Advanced Options

--warm-autoload

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 ls, doc, and show without having to instantiate them first.

Example:

psysh --warm-autoload

For fine-grained control, use the [[warmAutoload config option|Config options#warmautoload]].

--yolo

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.

Usage Examples

Force colors and compact output

psysh --color --compact

Run non-interactively with stdin

echo '<?php echo "Hello World";' | psysh --no-interactive

Use custom config and enable autoload warming

psysh --config /path/to/config.php --warm-autoload

Debug verbosity with color

psysh -vvv --color

Execute code from a file

psysh < script.php

Quiet mode with raw output

echo '<?php return 42;' | psysh --quiet --raw-output

Combining with Configuration

Command line options override configuration file settings. For example:

# This will use compact output even if your config.php sets compact to false
psysh --compact

Environment Variables

PsySH respects several environment variables to control its behavior and locate configuration files.

PsySH-Specific Variables

  • PSYSH_CONFIG - Path to config file (same as --config)
  • PSYSH_IGNORE_ENV - Set to 1 to 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

Terminal Variables

  • TERM - Terminal type (PsySH disables colors if set to dumb)

XDG Base Directory Variables

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/
psysh

Note: On Windows, PsySH uses %APPDATA%\PsySH for both config and data instead of XDG paths.

Clone this wiki locally