Documentation

Psy

Namespaces

CodeCleaner
Command
Exception
ExecutionLoop
Formatter
Input
Output
Readline
Reflection
Sudo
TabCompletion
Util
VarDumper
VersionUpdater
Test

Interfaces, Classes and Traits

ContextAware
ContextAware interface.
CodeCleaner
A service to clean up user input, detect parse errors before they happen, and generally work around issues with the PHP code evaluation experience.
ConfigPaths
A Psy Shell configuration path helper.
Configuration
The Psy Shell configuration.
ConsoleColorFactory
Builds `ConsoleColor` instances configured according to the given color mode.
Context
The Shell execution context.
ExecutionClosure
The Psy Shell's execution scope.
ExecutionLoop
The Psy Shell execution loop.
ExecutionLoopClosure
The Psy Shell's execution loop scope.
ParserFactory
Parser factory to abstract over PHP parser library versions.
Shell
The Psy Shell application.
Sudo
Helpers for bypassing visibility restrictions, mostly used in code generated by the `sudo` command.

Table of Contents

sh()  : string
Command to return the eval-able code to startup PsySH.
debug()  : array<string|int, mixed>
Invoke a Psy Shell from the current context.
info()  : array<string|int, mixed>|null
Get a bunch of debugging info about the current PsySH environment and configuration.
bin()  : Closure
`psysh` command line executable.

Functions

sh()

Command to return the eval-able code to startup PsySH.

sh() : string

eval(\Psy\sh());

Return values
string

debug()

Invoke a Psy Shell from the current context.

debug([array<string|int, mixed> $vars = [] ][, object|string $bindTo = null ]) : array<string|int, mixed>

For example:

foreach ($items as $item) {
    \Psy\debug(get_defined_vars());
}

If you would like your shell interaction to affect the state of the current context, you can extract() the values returned from this call:

foreach ($items as $item) {
    extract(\Psy\debug(get_defined_vars()));
    var_dump($item); // will be whatever you set $item to in Psy Shell
}

Optionally, supply an object as the $bindTo parameter. This determines the value $this will have in the shell, and sets up class scope so that private and protected members are accessible:

class Foo {
    function bar() {
        \Psy\debug(get_defined_vars(), $this);
    }
}

For the static equivalent, pass a class name as the $bindTo parameter. This makes self work in the shell, and sets up static scope so that private and protected static members are accessible:

class Foo {
    static function bar() {
        \Psy\debug(get_defined_vars(), get_called_class());
    }
}
Parameters
$vars : array<string|int, mixed> = []

Scope variables from the calling context (default: array())

$bindTo : object|string = null

Bound object ($this) or class (self) value for the shell

Return values
array<string|int, mixed>

Scope variables from the debugger session

info()

Get a bunch of debugging info about the current PsySH environment and configuration.

info([Configuration|null $config = null ]) : array<string|int, mixed>|null

If a Configuration param is passed, that configuration is stored and used for the current shell session, and no debugging info is returned.

Parameters
$config : Configuration|null = null
Return values
array<string|int, mixed>|null

bin()

`psysh` command line executable.

bin() : Closure
Return values
Closure

Search results