Skip to content

Commands

Justin Hileman edited this page Oct 14, 2025 · 5 revisions

πŸ“’ Commands

Running commands

To run a command, enter its name at the prompt, followed by any arguments that it accepts:

>>> $a = $b = 'c'
=> "c"
>>> ls -al

Variables:
  $a   "c"
  $b   "c"
  $_   "c"
>>>

In the extremely unlikely case that your command name conflicts with some PHP code you actually want to run, you can prefix your input with a semicolon to prevent commands from running:

>>> const help = 'HELP ME!'
=> true
>>> help
  help       Show a list of commands. Type `help [foo]` for information about [foo].      Aliases: ?
  ls         List local, instance or class variables, methods and constants.              Aliases: list, dir
  dump       Dump an object or primitive.
  doc        Read the documentation for an object, class, constant, method or property.   Aliases: rtfm, man
  show       Show the code for an object, class, constant, method or property.
  ...
>>> ;help
=> "HELP ME!"
>>>

The help command

The help command will print a list of all commands currently available in PsySH, along with a short description of what each command does:

>>> help
  help       Show a list of commands. Type `help [foo]` for information about [foo].      Aliases: ?
  ls         List local, instance or class variables, methods and constants.              Aliases: list, dir
  dump       Dump an object or primitive.
  doc        Read the documentation for an object, class, constant, method or property.   Aliases: rtfm, man
  show       Show the code for an object, class, constant, method or property.
  ...
>>>

The help command can also show more informationβ€”including usage and examplesβ€”about a specific command:

>>> help dump
Usage:
 dump [--depth DEPTH] [-a|--all] [--] <target>

Arguments:
 target     A target object or primitive to dump.

Options:
 --depth    Depth to parse (default: 10)
 --all (-a) Include private and protected methods and properties.

Help:
 Dump an object or primitive.

 This is like var_dump but way awesomer.

 e.g.
 >>> dump $_
 >>> dump $someVar

>>>

Built-in commands

  • buffer β€” Show (or clear) the contents of the code input buffer.
  • clear β€” Clear the Psy Shell screen.
  • doc β€” Read the documentation for an object, class, constant, method or property.
  • dump β€” Dump an object or primitive.
  • edit β€” Open an external editor. Afterwards, get produced code in input buffer.
  • exit β€” End the current session and return to caller.
  • help β€” Show a list of commands. Type help [foo] for information about [foo].
  • history β€” Show the Psy Shell history.
  • ls β€” List local, instance or class variables, methods and constants.
  • show β€” Show the code for an object, class, constant, method or property.
  • sudo β€” Evaluate PHP code, bypassing visibility restrictions.
  • throw-up β€” Throw an exception out of the Psy Shell.
  • timeit β€” Profiles with a timer.
  • trace β€” Show the current call stack.
  • whereami β€” Show where you are in the code.
  • wtf β€” Show the backtrace of the most recent exception.

Namespace-aware commands

The ls, doc, and show commands resolve class names using the current namespace and use statements, just like code execution does. This means you can reference classes by their short name:

>>> namespace App\Models;
>>> use Illuminate\Database\Eloquent\Model as EloquentModel;
>>> doc User            // Resolves to App\Models\User
>>> show EloquentModel  // Resolves to Illuminate\Database\Eloquent\Model
>>> ls Model            // Lists members of Illuminate\Database\Eloquent\Model

Combine with warmAutoload and implicitUse configuration for the best experience!

Clone this wiki locally