Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
💲 System shell integration
It can be super useful to access a system shell from inside a REPL session. PsySH fully supports this … but mostly because PHP supports this 😛.
Execute arbitrary shell commands
To execute arbitrary shell commands, wrap the command in backticks.
>>> `pwd` => "/Projects/psysh\n" >>> `ls` => """ CONTRIBUTING.md\n LICENSE\n README.md\n bin\n composer.json\n composer.lock\n phpunit.xml.dist\n src\n test\n vendor\n """ >>>
PHP variables can be interpolated into shell commands as well.
>>> $readme = 'README.md' => "README.md" >>> `ls -al $readme` => "-rw-r--r-- 1 justin staff 9649 May 28 13:34 README.md\n" >>>
✨ Shell commands with magic variables
Some commands—such as
$__line magic variables after they run. These variables are especially useful when interpolated into shell commands.
For example, after using
doc to show the documentation for a class or method, you can use the
subl shell command to open that file in Sublime Text and jump to the definition.
>>> doc Psy\Shell class Psy\Shell extends Symfony\Component\Console\Application Description: The Psy Shell application. Usage: $shell = new Shell; $shell->run(); Author: Justin Hileman <firstname.lastname@example.org> >>> $__file => "/Projects/psysh/src/Psy/Shell.php" >>> `subl $__file:$__line` => null >>>
This. Is. So. Good.