psysh
Debug and interactively experiment with PHP code
TLDR
Open a shell in the current directory
Open a shell in a specific directory
Use a specific configuration file
SYNOPSIS
psysh [options] [file]
PARAMETERS
--version
Display the PsySH version.
--help
Display help information.
--no-colors
Disable colors in output.
--config [file]
Specify a configuration file to load.
[file]
Execute the specified PHP file.
DESCRIPTION
PsySH is an interactive debugger and REPL (Read-Eval-Print Loop) for PHP. It provides a powerful and flexible environment for inspecting code, experimenting with different approaches, and debugging issues in real-time.
Unlike traditional debuggers that require restarting execution after each change, PsySH allows modifying code and immediately seeing the results within the running environment.
It offers features like code completion, history, variable inspection, and even integration with external editors. PsySH is invaluable for both development and production environments.
CAVEATS
Requires PHP 5.4 or greater. Needs `readline` or `pcntl` extension to provide full interactive features. May not work in some restricted environments.
USAGE EXAMPLES
To start an interactive PsySH session, simply type `psysh` in your terminal.
To execute a PHP file within PsySH, use `psysh myfile.php`.
Once in PsySH, you can interact with variables, call functions, and evaluate expressions directly.
CONFIGURATION
PsySH can be configured through a configuration file, allowing customization of its behavior, such as prompt, colors, and other settings. By default, it will look for `.psyshrc.php` in the current working directory, and your home directory (~/.psyshrc.php).
HISTORY
PsySH was initially developed by Justin Hileman and has become a popular tool within the PHP community. It addresses the limitations of traditional debugging methods by offering an interactive and immediate way to interact with code.
Its usage has grown significantly as developers embrace its efficiency for rapid prototyping, debugging, and exploring the behavior of PHP applications.
SEE ALSO
php(1), xdebug(1)