Configuration
in package
The Psy Shell configuration.
Table of Contents
- COLOR_MODE_AUTO = 'auto'
- COLOR_MODE_DISABLED = 'disabled'
- COLOR_MODE_FORCED = 'forced'
- $autoCompleter : mixed
- $AVAILABLE_OPTIONS : mixed
- $checker : mixed
- $cleaner : mixed
- $colorMode : mixed
- $configDir : mixed
- $configFile : mixed
- $dataDir : mixed
- $defaultIncludes : mixed
- $eraseDuplicates : mixed
- $errorLoggingLevel : mixed
- $forceArrayIndexes : mixed
- $hasPcntl : mixed
- $hasReadline : mixed
- $historyFile : string|false
- $historySize : mixed
- $manualDb : mixed
- $manualDbFile : mixed
- $newCommands : mixed
- $newMatchers : mixed
- $output : mixed
- $pager : mixed
- $presenter : mixed
- $prompt : mixed
- $readline : mixed
- $requireSemicolons : mixed
- $runtimeDir : mixed
- $shell : mixed
- $startupMessage : mixed
- $updateCheck : mixed
- $useBracketedPaste : mixed
- $usePcntl : mixed
- $useReadline : mixed
- $useTabCompletion : mixed
- $useUnicode : mixed
- $warnOnMultipleConfigs : mixed
- __construct() : mixed
- Construct a Configuration instance.
- addCasters() : mixed
- Add an array of casters definitions.
- addCommands() : mixed
- Add commands to the Shell.
- addMatchers() : mixed
- Add tab completion matchers to the AutoCompleter.
- addTabCompletionMatchers() : mixed
- colorMode() : string
- Get the current color mode.
- errorLoggingLevel() : int
- Get the current error logging level.
- forceArrayIndexes() : bool
- Get the force array indexes.
- getAutoCompleter() : AutoCompleter
- Get an AutoCompleter service instance.
- getChecker() : Checker
- Get an update checker service instance.
- getCodeCleaner() : CodeCleaner
- Get a CodeCleaner service instance.
- getConfigDir() : string
- Get the current configuration directory, if any is explicitly set.
- getConfigFile() : string
- Get the current PsySH config file.
- getDataDir() : string
- Get the current data directory, if any is explicitly set.
- getDefaultIncludes() : array<string|int, mixed>
- Get files to be included by default at the start of each shell session.
- getEraseDuplicates() : bool
- Get whether readline erases old duplicate history entries.
- getHistoryFile() : string
- Get the readline history file path.
- getHistorySize() : int
- Get the readline max history size.
- getLocalConfigFile() : string
- Get the local PsySH config file.
- getManualDb() : PDO
- Get a PHP manual database connection.
- getManualDbFile() : string
- Get the current PHP manual database file.
- getOutput() : ShellOutput
- Get a Shell Output service instance.
- getOutputDecorated() : null|bool
- Get the decoration (i.e. color) setting for the Shell Output service.
- getPager() : string|OutputPager
- Get an OutputPager instance or a command for an external Proc pager.
- getPipe() : string
- Get a filename suitable for a FIFO pipe of $type for process $pid.
- getPresenter() : Presenter
- Get the Presenter service.
- getPrompt() : string
- Get the prompt.
- getReadline() : Readline
- Get the Psy Shell readline service.
- getRuntimeDir() : string
- Get the shell's temporary directory location.
- getStartupMessage() : string|null
- Get the startup message.
- getTabCompletion() : bool
- getTabCompletionMatchers() : array<string|int, mixed>
- getTempFile() : string
- Get a temporary file of type $type for process $pid.
- getUpdateCheck() : string
- Get the current update check interval.
- getUpdateCheckCacheFile() : string|false
- Get a cache file path for the update checker.
- hasPcntl() : bool
- Check whether this PHP instance has Pcntl available.
- hasReadline() : bool
- Check whether this PHP instance has Readline available.
- init() : mixed
- Initialize the configuration.
- loadConfig() : mixed
- Load configuration values from an array of options.
- loadConfigFile() : mixed
- Load a configuration file (default: `$HOME/.config/psysh/config.php`).
- requireSemicolons() : bool
- Check whether to require semicolons on all statements.
- setAutoCompleter() : mixed
- Set the Shell AutoCompleter service.
- setChecker() : mixed
- Set an update checker service instance.
- setCodeCleaner() : mixed
- Set a CodeCleaner service instance.
- setColorMode() : mixed
- Set the current color mode.
- setConfigDir() : mixed
- Set the shell's config directory location.
- setDataDir() : mixed
- Set the shell's data directory location.
- setDefaultIncludes() : mixed
- Set files to be included by default at the start of each shell session.
- setEraseDuplicates() : mixed
- Sets whether readline erases old duplicate history entries.
- setErrorLoggingLevel() : mixed
- Set the error logging level.
- setForceArrayIndexes() : mixed
- Set the force array indexes.
- setHistoryFile() : mixed
- Set the readline history file path.
- setHistorySize() : mixed
- Set the readline max history size.
- setManualDbFile() : mixed
- Set the PHP manual database file.
- setOutput() : mixed
- Set the Shell Output service.
- setPager() : mixed
- Set the OutputPager service.
- setPrompt() : mixed
- Set the prompt.
- setReadline() : mixed
- Set the Psy Shell readline service.
- setRequireSemicolons() : mixed
- Enable or disable strict requirement of semicolons.
- setRuntimeDir() : mixed
- Set the shell's temporary directory location.
- setShell() : mixed
- Set the Shell backreference and add any new commands to the Shell.
- setStartupMessage() : mixed
- Set the startup message.
- setTabCompletion() : mixed
- setUpdateCheck() : mixed
- Set the update check interval.
- setUseBracketedPaste() : mixed
- Enable or disable bracketed paste.
- setUsePcntl() : mixed
- Enable or disable Pcntl usage.
- setUseReadline() : mixed
- Enable or disable Readline usage.
- setUseTabCompletion() : mixed
- Enable or disable tab completion.
- setUseUnicode() : mixed
- Enable or disable Unicode in PsySH specific output.
- setWarnOnMultipleConfigs() : mixed
- Enable or disable warnings on multiple configuration or data files.
- useBracketedPaste() : bool
- Check whether to use bracketed paste with readline.
- usePcntl() : bool
- Check whether to use Pcntl.
- useReadline() : bool
- Check whether to use Readline.
- useTabCompletion() : bool
- Check whether to use tab completion.
- useUnicode() : bool
- Check whether to use Unicode in PsySH specific output.
- warnOnMultipleConfigs() : bool
- Check whether to warn on multiple configuration or data files.
- doAddCommands() : mixed
- Internal method for adding commands. This will set any new commands once a Shell is available.
- doAddMatchers() : mixed
- Internal method for adding tab completion matchers. This will set any new matchers once a Shell is available.
- getReadlineClass() : string
- Get the appropriate Readline implementation class name.
Constants
COLOR_MODE_AUTO
public
mixed
COLOR_MODE_AUTO
= 'auto'
COLOR_MODE_DISABLED
public
mixed
COLOR_MODE_DISABLED
= 'disabled'
COLOR_MODE_FORCED
public
mixed
COLOR_MODE_FORCED
= 'forced'
Properties
$autoCompleter
private
mixed
$autoCompleter
$AVAILABLE_OPTIONS
private
static mixed
$AVAILABLE_OPTIONS
= ['codeCleaner', 'colorMode', 'configDir', 'dataDir', 'defaultIncludes', 'eraseDuplicates', 'errorLoggingLevel', 'forceArrayIndexes', 'historySize', 'manualDbFile', 'pager', 'prompt', 'requireSemicolons', 'runtimeDir', 'startupMessage', 'updateCheck', 'useBracketedPaste', 'usePcntl', 'useReadline', 'useTabCompletion', 'useUnicode', 'warnOnMultipleConfigs']
$checker
private
mixed
$checker
$cleaner
private
mixed
$cleaner
$colorMode
private
mixed
$colorMode
$configDir
private
mixed
$configDir
$configFile
private
mixed
$configFile
$dataDir
private
mixed
$dataDir
$defaultIncludes
private
mixed
$defaultIncludes
$eraseDuplicates
private
mixed
$eraseDuplicates
$errorLoggingLevel
private
mixed
$errorLoggingLevel
= E_ALL
$forceArrayIndexes
private
mixed
$forceArrayIndexes
= false
$hasPcntl
private
mixed
$hasPcntl
$hasReadline
private
mixed
$hasReadline
$historyFile
private
string|false
$historyFile
$historySize
private
mixed
$historySize
$manualDb
private
mixed
$manualDb
$manualDbFile
private
mixed
$manualDbFile
$newCommands
private
mixed
$newCommands
= []
$newMatchers
private
mixed
$newMatchers
= []
$output
private
mixed
$output
$pager
private
mixed
$pager
$presenter
private
mixed
$presenter
$prompt
private
mixed
$prompt
$readline
private
mixed
$readline
$requireSemicolons
private
mixed
$requireSemicolons
= false
$runtimeDir
private
mixed
$runtimeDir
$shell
private
mixed
$shell
$startupMessage
private
mixed
$startupMessage
$updateCheck
private
mixed
$updateCheck
$useBracketedPaste
private
mixed
$useBracketedPaste
$usePcntl
private
mixed
$usePcntl
$useReadline
private
mixed
$useReadline
$useTabCompletion
private
mixed
$useTabCompletion
$useUnicode
private
mixed
$useUnicode
$warnOnMultipleConfigs
private
mixed
$warnOnMultipleConfigs
= false
Methods
__construct()
Construct a Configuration instance.
public
__construct([array<string|int, mixed> $config = [] ]) : mixed
Optionally, supply an array of configuration values to load.
Parameters
- $config : array<string|int, mixed> = []
-
Optional array of configuration values
Return values
mixed —addCasters()
Add an array of casters definitions.
public
addCasters(array<string|int, mixed> $casters) : mixed
Parameters
- $casters : array<string|int, mixed>
Return values
mixed —addCommands()
Add commands to the Shell.
public
addCommands(array<string|int, mixed> $commands) : mixed
This will buffer new commands in the event that the Shell has not yet been instantiated. This allows the user to specify commands in their config rc file, despite the fact that their file is needed in the Shell constructor.
Parameters
- $commands : array<string|int, mixed>
Return values
mixed —addMatchers()
Add tab completion matchers to the AutoCompleter.
public
addMatchers(array<string|int, mixed> $matchers) : mixed
This will buffer new matchers in the event that the Shell has not yet been instantiated. This allows the user to specify matchers in their config rc file, despite the fact that their file is needed in the Shell constructor.
Parameters
- $matchers : array<string|int, mixed>
Return values
mixed —addTabCompletionMatchers()
public
addTabCompletionMatchers(array<string|int, mixed> $matchers) : mixed
Parameters
- $matchers : array<string|int, mixed>
Tags
Return values
mixed —colorMode()
Get the current color mode.
public
colorMode() : string
Return values
string —errorLoggingLevel()
Get the current error logging level.
public
errorLoggingLevel() : int
By default, PsySH will automatically log all errors, regardless of the
current error_reporting level. Additionally, if the error_reporting
level warrants, an ErrorException will be thrown.
Set errorLoggingLevel to 0 to prevent logging non-thrown errors. Set it
to any valid error_reporting value to log only errors which match that
level.
http://php.net/manual/en/function.error-reporting.php
Return values
int —forceArrayIndexes()
Get the force array indexes.
public
forceArrayIndexes() : bool
Return values
bool —getAutoCompleter()
Get an AutoCompleter service instance.
public
getAutoCompleter() : AutoCompleter
Return values
AutoCompleter —getChecker()
Get an update checker service instance.
public
getChecker() : Checker
If none has been explicitly defined, this will create a new instance.
Return values
Checker —getCodeCleaner()
Get a CodeCleaner service instance.
public
getCodeCleaner() : CodeCleaner
If none has been explicitly defined, this will create a new instance.
Return values
CodeCleaner —getConfigDir()
Get the current configuration directory, if any is explicitly set.
public
getConfigDir() : string
Return values
string —getConfigFile()
Get the current PsySH config file.
public
getConfigFile() : string
If a configFile option was passed to the Configuration constructor,
this file will be returned. If not, all possible config directories will
be searched, and the first config.php or rc.php file which exists
will be returned.
If you're trying to decide where to put your config file, pick
~/.config/psysh/config.php
Return values
string —getDataDir()
Get the current data directory, if any is explicitly set.
public
getDataDir() : string
Return values
string —getDefaultIncludes()
Get files to be included by default at the start of each shell session.
public
getDefaultIncludes() : array<string|int, mixed>
Return values
array<string|int, mixed> —getEraseDuplicates()
Get whether readline erases old duplicate history entries.
public
getEraseDuplicates() : bool
Return values
bool —getHistoryFile()
Get the readline history file path.
public
getHistoryFile() : string
Defaults to /history inside the shell's base config dir unless
explicitly overridden.
Return values
string —getHistorySize()
Get the readline max history size.
public
getHistorySize() : int
Return values
int —getLocalConfigFile()
Get the local PsySH config file.
public
getLocalConfigFile() : string
Searches for a project specific config file .psysh.php in the current
working directory.
Return values
string —getManualDb()
Get a PHP manual database connection.
public
getManualDb() : PDO
Return values
PDO —getManualDbFile()
Get the current PHP manual database file.
public
getManualDbFile() : string
Return values
string —Default: '~/.local/share/psysh/php_manual.sqlite'
getOutput()
Get a Shell Output service instance.
public
getOutput() : ShellOutput
If none has been explicitly provided, this will create a new instance with VERBOSITY_NORMAL and the output page supplied by self::getPager
Tags
Return values
ShellOutput —getOutputDecorated()
Get the decoration (i.e. color) setting for the Shell Output service.
public
getOutputDecorated() : null|bool
Return values
null|bool —3-state boolean corresponding to the current color mode
getPager()
Get an OutputPager instance or a command for an external Proc pager.
public
getPager() : string|OutputPager
If no Pager has been explicitly provided, and Pcntl is available, this
will default to cli.pager ini value, falling back to which less.
Return values
string|OutputPager —getPipe()
Get a filename suitable for a FIFO pipe of $type for process $pid.
public
getPipe(string $type, int $pid) : string
The pipe will be created inside the current temporary directory.
Parameters
- $type : string
- $pid : int
Return values
string —Pipe name
getPresenter()
Get the Presenter service.
public
getPresenter() : Presenter
Return values
Presenter —getPrompt()
Get the prompt.
public
getPrompt() : string
Return values
string —getReadline()
Get the Psy Shell readline service.
public
getReadline() : Readline
By default, this service uses (in order of preference):
- GNU Readline
- Libedit
- A transient array-based readline emulation.
Return values
Readline —getRuntimeDir()
Get the shell's temporary directory location.
public
getRuntimeDir() : string
Defaults to /psysh inside the system's temp dir unless explicitly
overridden.
Return values
string —getStartupMessage()
Get the startup message.
public
getStartupMessage() : string|null
Return values
string|null —getTabCompletion()
public
getTabCompletion() : bool
Tags
Return values
bool —getTabCompletionMatchers()
public
getTabCompletionMatchers() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getTempFile()
Get a temporary file of type $type for process $pid.
public
getTempFile(string $type, int $pid) : string
The file will be created inside the current temporary directory.
Parameters
- $type : string
- $pid : int
Tags
Return values
string —Temporary file name
getUpdateCheck()
Get the current update check interval.
public
getUpdateCheck() : string
One of 'always', 'daily', 'weekly', 'monthly' or 'never'. If none is explicitly set, default to 'weekly'.
Return values
string —getUpdateCheckCacheFile()
Get a cache file path for the update checker.
public
getUpdateCheckCacheFile() : string|false
Return values
string|false —Return false if config file/directory is not writable
hasPcntl()
Check whether this PHP instance has Pcntl available.
public
hasPcntl() : bool
Return values
bool —True if Pcntl is available
hasReadline()
Check whether this PHP instance has Readline available.
public
hasReadline() : bool
Return values
bool —True if Readline is available
init()
Initialize the configuration.
public
init() : mixed
This checks for the presence of Readline and Pcntl extensions.
If a config file is available, it will be loaded and merged with the current config.
If no custom config file was specified and a local project config file is available, it will be loaded and merged with the current config.
Return values
mixed —loadConfig()
Load configuration values from an array of options.
public
loadConfig(array<string|int, mixed> $options) : mixed
Parameters
- $options : array<string|int, mixed>
Return values
mixed —loadConfigFile()
Load a configuration file (default: `$HOME/.config/psysh/config.php`).
public
loadConfigFile(string $file) : mixed
This configuration instance will be available to the config file as $config. The config file may directly manipulate the configuration, or may return an array of options which will be merged with the current configuration.
Parameters
- $file : string
Tags
Return values
mixed —requireSemicolons()
Check whether to require semicolons on all statements.
public
requireSemicolons() : bool
By default, PsySH will automatically insert semicolons at the end of
statements if they're missing. To strictly require semicolons, set
requireSemicolons to true.
Return values
bool —setAutoCompleter()
Set the Shell AutoCompleter service.
public
setAutoCompleter(AutoCompleter $autoCompleter) : mixed
Parameters
- $autoCompleter : AutoCompleter
Return values
mixed —setChecker()
Set an update checker service instance.
public
setChecker(Checker $checker) : mixed
Parameters
- $checker : Checker
Return values
mixed —setCodeCleaner()
Set a CodeCleaner service instance.
public
setCodeCleaner(CodeCleaner $cleaner) : mixed
Parameters
- $cleaner : CodeCleaner
Return values
mixed —setColorMode()
Set the current color mode.
public
setColorMode(string $colorMode) : mixed
Parameters
- $colorMode : string
Return values
mixed —setConfigDir()
Set the shell's config directory location.
public
setConfigDir(string $dir) : mixed
Parameters
- $dir : string
Return values
mixed —setDataDir()
Set the shell's data directory location.
public
setDataDir(string $dir) : mixed
Parameters
- $dir : string
Return values
mixed —setDefaultIncludes()
Set files to be included by default at the start of each shell session.
public
setDefaultIncludes([array<string|int, mixed> $includes = [] ]) : mixed
Parameters
- $includes : array<string|int, mixed> = []
Return values
mixed —setEraseDuplicates()
Sets whether readline erases old duplicate history entries.
public
setEraseDuplicates(bool $value) : mixed
Parameters
- $value : bool
Return values
mixed —setErrorLoggingLevel()
Set the error logging level.
public
setErrorLoggingLevel(bool $errorLoggingLevel) : mixed
Parameters
- $errorLoggingLevel : bool
Tags
Return values
mixed —setForceArrayIndexes()
Set the force array indexes.
public
setForceArrayIndexes(bool $forceArrayIndexes) : mixed
Parameters
- $forceArrayIndexes : bool
Return values
mixed —setHistoryFile()
Set the readline history file path.
public
setHistoryFile(string $file) : mixed
Parameters
- $file : string
Return values
mixed —setHistorySize()
Set the readline max history size.
public
setHistorySize(int $value) : mixed
Parameters
- $value : int
Return values
mixed —setManualDbFile()
Set the PHP manual database file.
public
setManualDbFile(string $filename) : mixed
This file should be an SQLite database generated from the phpdoc source
with the bin/build_manual script.
Parameters
- $filename : string
Return values
mixed —setOutput()
Set the Shell Output service.
public
setOutput(ShellOutput $output) : mixed
Parameters
- $output : ShellOutput
Return values
mixed —setPager()
Set the OutputPager service.
public
setPager(string|OutputPager $pager) : mixed
If a string is supplied, a ProcOutputPager will be used which shells out to the specified command.
Parameters
- $pager : string|OutputPager
Tags
Return values
mixed —setPrompt()
Set the prompt.
public
setPrompt(string $prompt) : mixed
Parameters
- $prompt : string
Return values
mixed —setReadline()
Set the Psy Shell readline service.
public
setReadline(Readline $readline) : mixed
Parameters
- $readline : Readline
Return values
mixed —setRequireSemicolons()
Enable or disable strict requirement of semicolons.
public
setRequireSemicolons(bool $requireSemicolons) : mixed
Parameters
- $requireSemicolons : bool
Tags
Return values
mixed —setRuntimeDir()
Set the shell's temporary directory location.
public
setRuntimeDir(string $dir) : mixed
Parameters
- $dir : string
Return values
mixed —setShell()
Set the Shell backreference and add any new commands to the Shell.
public
setShell(Shell $shell) : mixed
Parameters
- $shell : Shell
Return values
mixed —setStartupMessage()
Set the startup message.
public
setStartupMessage(string $message) : mixed
Parameters
- $message : string
Return values
mixed —setTabCompletion()
public
setTabCompletion(bool $useTabCompletion) : mixed
Parameters
- $useTabCompletion : bool
Tags
Return values
mixed —setUpdateCheck()
Set the update check interval.
public
setUpdateCheck(string $interval) : mixed
Parameters
- $interval : string
Tags
Return values
mixed —setUseBracketedPaste()
Enable or disable bracketed paste.
public
setUseBracketedPaste(bool $useBracketedPaste) : mixed
Note that this only works with readline (not libedit) integration for now.
Parameters
- $useBracketedPaste : bool
Return values
mixed —setUsePcntl()
Enable or disable Pcntl usage.
public
setUsePcntl(bool $usePcntl) : mixed
Parameters
- $usePcntl : bool
Return values
mixed —setUseReadline()
Enable or disable Readline usage.
public
setUseReadline(bool $useReadline) : mixed
Parameters
- $useReadline : bool
Return values
mixed —setUseTabCompletion()
Enable or disable tab completion.
public
setUseTabCompletion(bool $useTabCompletion) : mixed
Parameters
- $useTabCompletion : bool
Return values
mixed —setUseUnicode()
Enable or disable Unicode in PsySH specific output.
public
setUseUnicode(bool $useUnicode) : mixed
Note that this does not disable Unicode output in general, it just makes it so PsySH won't output any itself.
Parameters
- $useUnicode : bool
Return values
mixed —setWarnOnMultipleConfigs()
Enable or disable warnings on multiple configuration or data files.
public
setWarnOnMultipleConfigs(bool $warnOnMultipleConfigs) : mixed
Parameters
- $warnOnMultipleConfigs : bool
Tags
Return values
mixed —useBracketedPaste()
Check whether to use bracketed paste with readline.
public
useBracketedPaste() : bool
When this works, it's magical. Tabs in pastes don't try to autcomplete. Newlines in paste don't execute code until you get to the end. It makes readline act like you'd expect when pasting.
But it often (usually?) does not work. And when it doesn't, it just spews escape codes all over the place and generally makes things ugly :(
If useBracketedPaste has been set to true, but the current readline
implementation is anything besides GNU readline, this will return false.
Return values
bool —True if the shell should use bracketed paste
usePcntl()
Check whether to use Pcntl.
public
usePcntl() : bool
If setUsePcntl has been set to true, but Pcntl is not actually
available, this will return false.
Return values
bool —True if the current Shell should use Pcntl
useReadline()
Check whether to use Readline.
public
useReadline() : bool
If setUseReadline as been set to true, but Readline is not actually
available, this will return false.
Return values
bool —True if the current Shell should use Readline
useTabCompletion()
Check whether to use tab completion.
public
useTabCompletion() : bool
If setUseTabCompletion has been set to true, but readline is not
actually available, this will return false.
Return values
bool —True if the current Shell should use tab completion
useUnicode()
Check whether to use Unicode in PsySH specific output.
public
useUnicode() : bool
Note that this does not disable Unicode output in general, it just makes it so PsySH won't output any itself.
Return values
bool —warnOnMultipleConfigs()
Check whether to warn on multiple configuration or data files.
public
warnOnMultipleConfigs() : bool
By default, PsySH will use the file with highest precedence, and will silently ignore all others. With this enabled, a warning will be emitted (but not an exception thrown) if multiple configuration or data files are found.
This will default to true in a future release, but is false for now.
Return values
bool —doAddCommands()
Internal method for adding commands. This will set any new commands once a Shell is available.
private
doAddCommands() : mixed
Return values
mixed —doAddMatchers()
Internal method for adding tab completion matchers. This will set any new matchers once a Shell is available.
private
doAddMatchers() : mixed
Return values
mixed —getReadlineClass()
Get the appropriate Readline implementation class name.
private
getReadlineClass() : string