Starting the REPL
Execute PHP Code
Type any PHP expression at the prompt:
The
=> prefix shows the return value of your expression.Interactive Features
Multi-line Input
PsySH automatically detects incomplete statements and prompts for more input:Code Buffer Management
The code buffer holds your multi-line input as you type:Buffer Commands
Buffer Commands
- clear - Clear the code buffer
- buffer - Show the current code buffer contents
- Press Ctrl+D while in an incomplete expression to clear the buffer
Loading Files
Include Files at Startup
Load PHP files when starting PsySH:Include Files During Session
Use standard PHP include statements:Working with Output
Return Values
Every expression shows its return value:Standard Output
Printed output appears without the=> prefix:
Lines ending without a newline show a special indicator (
⏎) to make it clear where output ends.Exiting the REPL
- exit command
- Keyboard Shortcut
Use the
exit command:Error Handling
PsySH catches exceptions and displays them with helpful formatting:Tab Completion
Press Tab to autocomplete:- Variable names:
$my→$myVariable - Function names:
array_→ shows all array functions - Class names:
Date→DateTime,DateTimeZone, etc. - Object methods:
$obj->→ shows all methods - Constants:
PHP_→ shows PHP constants
Configuration
PsySH looks for configuration in:~/.config/psysh/config.php~/.psysh/rc.php.psysh.phpin the current directory (project-specific)
Example Configuration
Interactive vs Non-Interactive Mode
Non-Interactive Mode
Execute PHP code from stdin:Raw Output Mode
Use--raw-output for machine-readable output:
Working Directory
Set the working directory when starting PsySH:Input Validation
By default, PsySH validates and cleans your input before execution. This can be disabled with the--yolo flag: