Constructor
__construct(array $config = [])
Construct a Configuration instance.
Optionally supply an array of configuration values to load.
Array of configuration options
Static Methods
fromInput(InputInterface $input): self
Construct a Configuration object from Symfony Console input.
Great for adding psysh-compatible command line options to framework- or app-specific wrappers.
Symfony Console input (should be bound to an InputDefinition first)
Configuration instance
getInputOptions(): array
Get a list of input options expected when initializing Configuration via input.
Array of Symfony Console InputOption instances
Configuration Methods
loadConfig(array $options): void
Load configuration values from an array of options.
Configuration options
loadConfigFile(string $file): void
Load a configuration file (default: ~/.config/psysh/config.php).
The configuration instance is available to the config file as $config. The config file may directly manipulate the configuration, or return an array of options.
Path to configuration file
init(): void
Initialize the configuration.
Checks for Readline and Pcntl extensions. Loads config files if available.
File and Directory Methods
getConfigFile(): ?string
Get the current PsySH config file.
Searches for config.php or rc.php in config directories.
Config file path, or null if none exists
getLocalConfigFile(): ?string
Get the local PsySH config file (.psysh.php in current working directory).
Local config file path, or null
setConfigDir(string $dir): void
Set the shell’s config directory location.
Config directory path
getConfigDir(): ?string
Get the current configuration directory.
Config directory path, or null
setDataDir(string $dir): void
Set the shell’s data directory location.
Data directory path
getDataDir(): ?string
Get the current data directory.
Data directory path, or null
setRuntimeDir(string $dir): void
Set the shell’s temporary directory location.
Runtime directory path
getRuntimeDir(bool $create = true): string
Get the shell’s temporary directory location.
Defaults to /psysh inside the system’s temp dir.
Whether to create directory if it doesn’t exist
Runtime directory path
History Configuration
setHistoryFile(string $file): void
Set the readline history file path.
History file path
getHistoryFile(): ?string
Get the readline history file path.
Defaults to /history inside the shell’s config dir.
History file path, or null
setHistorySize(int $value): void
Set the readline max history size.
Maximum history entries
getHistorySize(): int
Get the readline max history size.
Maximum history entries (0 = unlimited)
setEraseDuplicates(bool $value): void
Set whether readline erases old duplicate history entries.
Whether to erase duplicates
getEraseDuplicates(): ?bool
Get whether readline erases old duplicate history entries.
True if duplicates are erased, null if not set
Includes
setDefaultIncludes(array $includes = []): void
Set files to be included by default at the start of each shell session.
Array of file paths
getDefaultIncludes(): array
Get files to be included by default at the start of each shell session.
Array of file paths
Readline Configuration
hasReadline(): bool
Check whether this PHP instance has Readline available.
True if Readline is available
setUseReadline(bool $useReadline): void
Enable or disable Readline usage.
Whether to use Readline
useReadline(): bool
Check whether to use Readline.
True if Readline should be used
setReadline(Readline\Readline $readline): void
Set the PsySH readline service.
Readline instance
getReadline(): Readline\Readline
Get the PsySH readline service.
By default uses GNU Readline, Libedit, or array-based emulation.
Readline instance
setUseBracketedPaste(bool $useBracketedPaste): void
Enable or disable bracketed paste.
Only works with GNU readline (not libedit).
Whether to use bracketed paste
useBracketedPaste(): bool
Check whether to use bracketed paste with readline.
True if bracketed paste should be used
Pcntl Configuration
hasPcntl(): bool
Check whether this PHP instance has Pcntl available.
True if Pcntl is available
setUsePcntl(bool $usePcntl): void
Enable or disable Pcntl usage.
Whether to use Pcntl
usePcntl(): bool
Check whether to use Pcntl.
True if Pcntl should be used
Output Configuration
setOutput(ShellOutput $output): void
Set the Shell Output service.
Output instance
getOutput(): ShellOutput
Get a Shell Output service instance.
Output instance
setRawOutput(bool $rawOutput): void
Enable or disable raw output.
Whether to use raw output
rawOutput(): bool
Check whether to use raw output (var_export style).
Set by --raw-output flag, only makes sense when non-interactive.
True if raw output is enabled
setPager($pager): void
Set the OutputPager service.
Can be a string (command name) or OutputPager instance. Use ‘cat’ or false to disable.
Pager command or instance
getPager(): string|OutputPager|false
Get an OutputPager instance or command for an external pager.
Pager command, instance, or false if disabled
Color and Theme Configuration
setColorMode(string $colorMode): void
Set the current color mode.
One of: ‘auto’, ‘forced’, ‘disabled’
colorMode(): string
Get the current color mode.
One of: ‘auto’, ‘forced’, ‘disabled’
setTheme($theme): void
Set the current output Theme.
Theme instance, name, or config array
theme(): Theme
Get the current output Theme.
Theme instance
Interactive Mode
setInteractiveMode(string $interactiveMode): void
Set the shell’s interactive mode.
One of: ‘auto’, ‘forced’, ‘disabled’
interactiveMode(): string
Get the current interactive mode.
One of: ‘auto’, ‘forced’, ‘disabled’
getInputInteractive(): bool
Get whether shell input is interactive.
True if input is interactive
Verbosity
setVerbosity(string $verbosity): void
Set the shell output verbosity.
One of: ‘quiet’, ‘normal’, ‘verbose’, ‘very_verbose’, ‘debug’
verbosity(): string
Get the configured output verbosity.
One of: ‘quiet’, ‘normal’, ‘verbose’, ‘very_verbose’, ‘debug’
getOutputVerbosity(): int
Map the verbosity configuration to OutputInterface verbosity constants.
Symfony Console OutputInterface verbosity level
Code Execution Configuration
setRequireSemicolons(bool $requireSemicolons): void
Enable or disable strict requirement of semicolons.
Whether to require semicolons
requireSemicolons(): bool
Check whether to require semicolons on all statements.
By default, PsySH will automatically insert semicolons if missing.
True if semicolons are required
setStrictTypes(bool $strictTypes): void
Enable or disable strict types enforcement.
Whether to enforce strict types
strictTypes(): bool
Check whether to enforce strict types.
True if strict types are enforced
setYolo(bool $yolo): void
Enable or disable running PsySH without input validation.
You don’t want this.
Whether to disable validation
yolo(): bool
Check whether to disable input validation.
True if validation is disabled
setCodeCleaner(CodeCleaner $cleaner): void
Set a CodeCleaner service instance.
CodeCleaner instance
getCodeCleaner(): CodeCleaner
Get a CodeCleaner service instance.
CodeCleaner instance
Error Handling
setErrorLoggingLevel(int $errorLoggingLevel): void
Set the error logging level.
Error level bitmask (e.g., E_ALL, E_WARNING)
errorLoggingLevel(): int
Get the current error logging level.
By default, PsySH logs all errors regardless of error_reporting level.
Error level bitmask
Unicode
setUseUnicode(bool $useUnicode): void
Enable or disable Unicode in PsySH specific output.
Whether to use Unicode
useUnicode(): bool
Check whether to use Unicode in PsySH specific output.
True if Unicode should be used
Tab Completion
setUseTabCompletion(bool $useTabCompletion): void
Enable or disable tab completion.
Whether to use tab completion
useTabCompletion(): bool
Check whether to use tab completion.
True if tab completion should be used
setAutoCompleter(AutoCompleter $autoCompleter): void
Set the Shell AutoCompleter service.
AutoCompleter instance
getAutoCompleter(): AutoCompleter
Get an AutoCompleter service instance.
AutoCompleter instance
addMatchers(array $matchers): void
Add tab completion matchers to the AutoCompleter.
Array of matcher instances
Autoload Warming
setWarmAutoload($config): void
Configure autoload warming.
False to disable, true for defaults, or array for custom config
getAutoloadWarmers(): array
Get configured autoload warmers.
Array of autoload warmer instances
Implicit Use
setImplicitUse($config): void
Set implicit use statement configuration.
Automatically adds use statements for unqualified class references.
False to disable, or array with includeNamespaces/excludeNamespaces
getImplicitUse(): bool|array
Get implicit use configuration.
Implicit use configuration
Logging
setLogging($logging): void
Configure logging.
Logs PsySH input, commands, and executed code.
PSR-3 logger, callback, or config array
getLogger(): ?ShellLogger
Get a ShellLogger instance if logging is configured.
Logger instance, or null
Commands and Matchers
addCommands(array $commands): void
Add commands to the Shell.
Array of Command instances
setShell(Shell $shell): void
Set the Shell backreference and add any new commands.
Shell instance
Manual Configuration
setManualDbFile(string $filename): void
Set the PHP manual database file.
Path to manual database file (SQLite or PHP)
getManualDbFile(): ?string
Get the current PHP manual database file.
Manual database file path, or null
getManual(): ?ManualInterface
Get a PHP manual instance.
Automatically detects format (v2 SQLite or v3 PHP).
Manual instance, or null if none available
Update Checking
setUpdateCheck(string $interval): void
Set the update check interval.
One of: ‘always’, ‘daily’, ‘weekly’, ‘monthly’, ‘never’
getUpdateCheck(): string
Get the current update check interval.
One of: ‘always’, ‘daily’, ‘weekly’, ‘monthly’, ‘never’
getChecker(): Checker
Get an update checker service instance.
Update checker instance
Project Trust
setTrustProject($mode): void
Configure the project trust mode.
Boolean, or one of: ‘prompt’, ‘always’, ‘never’
getProjectTrustMode(): string
Get the current project trust mode.
One of: ‘prompt’, ‘always’, ‘never’
Constants
Auto-detect color support (default)
Force color output
Disable color output
Auto-detect interactive mode (default)
Force interactive mode
Disable interactive mode
Prompt user for project trust (default)
Always trust projects
Never trust projects (restricted mode)
Quiet output level
Normal output level (default)
Verbose output level
Very verbose output level
Debug output level