Linux command
psysh 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Start PHP REPL
psysh
Start with specific config file
psysh -c [config.php]
Start with a specific working directory
psysh --cwd [path/to/project]
Run non-interactively from stdin
echo "echo 'hello';" | psysh -n
Start with compact output
psysh --compact
Start with autoload warming for better tab completion
psysh --warm-autoload
说明
psysh is a modern interactive PHP shell (REPL) that provides a powerful developer console with syntax highlighting, tab completion, and inline documentation. It allows executing PHP code interactively, inspecting variables, and testing snippets without creating script files. PsySH also functions as a runtime debugger when integrated into applications. By calling `eval(\Psy\sh())` in code, developers can drop into an interactive debugging session with access to the current scope's variables and context. It serves as the foundation for Laravel's tinker command.
参数
- -c, --config _FILE_
- Use alternate configuration file.
- --cwd _PATH_
- Use alternate working directory.
- -V, --version
- Display version number.
- -i, -a, --interactive
- Force interactive mode.
- -n, --no-interactive
- Force non-interactive mode (reads from stdin).
- -r, --raw-output
- Print var_export-style return values.
- --compact
- Run with compact output (minimal whitespace).
- -q, --quiet
- Suppress most output except results and errors.
- -v, -vv, -vvv, --verbose
- Increase message verbosity (up to three levels).
- --color
- Force colored output.
- --no-color
- Disable colored output.
- --warm-autoload
- Pre-load classes from Composer autoloader for better tab completion.
- --yolo
- Run with minimal input validation (debugging only).
- -u, --self-update
- Install newer version (PHAR installation only).
- --update-manual
- Download the latest PHP manual for inline documentation.
- -h, --help
- Display help message.
FAQ
What is the psysh command used for?
psysh is a modern interactive PHP shell (REPL) that provides a powerful developer console with syntax highlighting, tab completion, and inline documentation. It allows executing PHP code interactively, inspecting variables, and testing snippets without creating script files. PsySH also functions as a runtime debugger when integrated into applications. By calling `eval(\Psy\sh())` in code, developers can drop into an interactive debugging session with access to the current scope's variables and context. It serves as the foundation for Laravel's tinker command.
How do I run a basic psysh example?
Run `psysh` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c, --config _FILE_ do in psysh?
Use alternate configuration file.