PsySH Documentation

repository·main·Indexed 27 days ago

https://github.com/bobthecow/psysh

PsySH is a runtime developer console, interactive debugger, and REPL (Read–Eval–Print Loop) for PHP. It provides an interactive environment for executing code, inspecting variables, and debugging applications. Key features include a runtime configuration system via the `config` command, a `doc` command for reading PHP manual and docblock documentation, an `edit` command for external editor integration, and advanced inspection tools like `dump` and `ls`.

Tokens
4.4K
Snippets
18
Records
47
Agent score
95%

What's inside PsySH

  1. Configure PsySH project trust via environment variables

    main

    You can control whether PsySH trusts local project autoloader files by setting the PSYSH_TRUST_PROJECT environment variable. This is particularly useful in automated environments or CI/CD pipelines.

    Supported values:

    • true or 1: Trust the project.
    • false or 0: Do not trust the project.
  2. Parse code strings using CodeArgumentParser

    main

    The CodeArgumentParser class is used to lex and parse a string of PHP code into a list of statements. It is designed for processing code arguments provided via CLI.

    When using parse(), you should provide the raw PHP code string without a <?php opening tag. The class automatically prepends the tag and attempts to handle common syntax issues like missing trailing semicolons by retrying the parse with a semicolon appended if an 'unexpected EOF' error is encountered.

  3. Reference: `doc` command flags and arguments

    main

    The doc command definition includes the following inputs:

    TypeNameAliasDescription
    Optionall-aShow documentation for superclasses as well as the current class.
    Optionupdate-manual(none)Download and install the latest PHP manual (optional language code).
    Argumenttarget(none)Function, class, instance, constant, method or property to document.
  4. Reference: Runtime-configurable PsySH keys

    main

    The following keys are available for inspection or modification via the config command:

    verbosity
    useUnicode
    errorLoggingLevel
    clipboardCommand
    useOsc52Clipboard
    colorMode
    theme
    pager
    requireSemicolons
    semicolonsSuppressReturn
    useBracketedPaste
    useSyntaxHighlighting
    useSuggestions
  5. Configure the editor for the `edit` command

    main

    The edit command relies on the EDITOR environment variable to determine which external program to launch. To change the editor used by PsySH, set this variable in your shell environment.

    If the EDITOR variable is unset, PsySH will attempt to use nano by default.

  6. Reference: `show` command arguments and options

    main

    The following are the arguments and options available for the show command:

    TypeNameRequiredDescription
    ArgumenttargetNoFunction, class, instance, constant, method or property to show.
    Option--exNoShow last exception context. Optionally specify a stack index. (Default: 1)