Skip to main content
PsySH is a runtime developer console, interactive debugger and REPL for PHP. Think of it as an interactive playground where you can experiment with PHP code, debug applications, and explore your codebase in real-time.

What is PsySH?

PsySH provides a powerful interactive shell for PHP that allows you to:
  • Execute PHP code interactively and see results immediately
  • Debug your application at runtime by dropping into a shell
  • Inspect variables, objects, and application state
  • Explore classes, methods, and functions with built-in documentation
  • Test code snippets without creating temporary files

Installation

Get PsySH installed on your system via Composer, PHAR, or global install

Quick Start

Start using PsySH in minutes with practical examples

Commands

Explore built-in commands for inspecting code and managing your session

Configuration

Customize PsySH with themes, history settings, and more

Key Features

Interactive REPL

Run PHP code interactively and see results immediately:
>>> $greeting = "Hello, PsySH!"
=> "Hello, PsySH!"
>>> echo strtoupper($greeting)
HELLO, PSYSH!
=> null

Runtime Debugging

Drop into a debug shell anywhere in your code:
foreach ($items as $item) {
    \Psy\debug(get_defined_vars());
    // Interactive shell opens here with access to $items, $item, etc.
}

Code Introspection

Explore your code with built-in commands:
>>> ls -la \Psy\Shell
Class Methods:
  __construct   addInput      all           doRun
  find          get           getHelp       has
  run           setIncludes   ...

PHP Manual Integration

Access PHP documentation right from the shell:
>>> doc array_map
Function: array_map Applies the callback to the elements of the given arrays

Synopsis:
  array_map(callable $callback, array $array, array ...$arrays): array

Why PsySH?

PsySH is built on top of Symfony Console and nikic/php-parser, providing a robust and reliable development tool.
  • No setup required: Just install and start using it immediately
  • Framework integration: Works seamlessly with Laravel, Symfony, Drupal, and more
  • Powerful debugging: Set breakpoints with a single function call
  • Tab completion: Smart autocomplete for classes, functions, and variables
  • History management: Your command history is saved between sessions

Use Cases

Quick Experimentation

Test PHP features or library functions without creating test files:
>>> $data = json_decode('{"name":"John","age":30}', true)
=> [
     "name" => "John",
     "age" => 30,
   ]

Application Debugging

Inspect application state during runtime:
class UserController {
    public function show($id) {
        $user = User::find($id);
        \Psy\debug(get_defined_vars(), $this);
        return view('user.show', compact('user'));
    }
}

Learning and Teaching

Perfect for learning PHP or teaching concepts interactively:
>>> class Person {
...     public function __construct(public string $name) {}
... }
=> null
>>> $person = new Person("Alice")
=> Person {#123
     +name: "Alice",
   }

Requirements

PsySH requires:
  • PHP 7.4 or higher (PHP 8.0+ recommended)
  • The json extension (usually enabled by default)
  • The tokenizer extension (usually enabled by default)
For the best experience, install the pcntl and posix extensions. They enable features like command history and signal handling.

Next Steps

1

Install PsySH

Follow the installation guide to get PsySH set up on your system.
2

Try the Quick Start

Work through the quick start guide to learn the basics.
3

Explore Commands

Check out the commands reference to discover what PsySH can do.

Build docs developers (and LLMs) love