Runtime config and clipboard support
PsySH has a new config command for inspecting and updating runtime-configurable settings during the current session. You can tweak things like pager, theme, verbosity, useSuggestions, useSyntaxHighlighting, clipboardCommand, and semicolonsSuppressReturn without restarting the shell. Fixes #361
There’s also a new copy command for copying the last result ($_) or any expression to your clipboard. Works with system clipboard commands, or via OSC 52 for SSH and remote terminals.
Configure with clipboardCommand or useOsc52Clipboard in your config.
Semicolon-based return suppression
Optionally suppress return values by ending a statement with ;, similar to MATLAB/Octave behavior. Supports a 'double' mode requiring ;; for suppression (if requireSemicolons is also enabled, both true and 'double' require ;;).
'semicolonsSuppressReturn' => true,
'semicolonsSuppressReturn' => 'double', // Always require ;; to suppressOutput and exception display improvements
Strings are now valid PHP!
- PsySH now preserves backslashes and other characters it previously mangled in a few cases. Fixes #351, #568
- Multiline strings are rendered using heredoc-style output rather than triple-quoted strings
""". The old format is available viauseDeprecatedMultilineStringsuntil the next major release.
Providing an exceptionDetails callback via config renders additional context about exceptions (e.g. validation errors) alongside the error message. Fixes #648
A few other improvements:
- More consistent compact (and non-compact) output spacing.
- Responsive
helplayout adapts to terminal width.
Better completion for everyone
Legacy readline now shares PsySH’s newer completion engine, which brings much better parity between ext-readline/libedit and experimental interactive readline. Command argument completion, better multiline buffering, and a handful of command-dispatch edge cases now work much more consistently outside experimental readline too.
Commands can now define their own argument completions via CommandArgumentCompletionAware.
Interactive readline polish
New in the experimental interactive readline:
- Live syntax highlighting — code is highlighted as you type. Can be disabled via
useSyntaxHighlightingif you don't like colors, I guess. - Allman-style indenting — opening brackets on a new line get proper indentation.
- Improved auto-dedent — closing brackets automatically reduce indentation.
psy\info() and --info also report more detail about readline and autocomplete state.
Run psysh with --experimental-readline and try it out. It's getting kind of awesome!
Compatibility note
Bare config and copy at the prompt now resolve to PsySH commands before PHP function calls. Prefix ambiguous input with ; to force PHP execution.
Bug fixes
- Use aliases are now tracked by import type (class vs function vs constant), fixing resolution bugs with
use functionanduse conststatements. - Fix pager pipe warnings when user quits pager early
- Fix eval error messages incorrectly suppressing PsySH file paths
- Improve terminal width check on oldest supported Symfony versions
- Fix a code cleaner bug with
throw new Exceptionin PHP 7.4
Improvements
- Added
--pager/--no-pagerCLI options - Richer
psy\info()/--infooutput with interactive completion - Added hermetic test bootstrap, PTY smoketests, and additional downstream/composer-repl coverage
- Ctrl-C now interrupts the
editcommand instead of waiting for the editor to close