Skip to content

Instantly share code, notes, and snippets.

@Nex-Otaku
Last active March 1, 2021 20:57
Show Gist options
  • Save Nex-Otaku/705474874c9957a85912be76b184e34f to your computer and use it in GitHub Desktop.
Save Nex-Otaku/705474874c9957a85912be76b184e34f to your computer and use it in GitHub Desktop.
REPL shell command draft for Yii 3 application
<?php
namespace App\Command\Shell;
use Psy\Configuration;
use Psy\Shell;
use Psy\VersionUpdater\Checker;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ShellCommand extends Command
{
protected static $defaultName = 'shell';
protected function configure(): void
{
$this
->setDescription('Interactive shell')
->setHelp('Interactive shell a.k.a. REPL allows you to execute any application code directly as you type.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$config = Configuration::fromInput($input);
$config->setUpdateCheck(Checker::NEVER);
$shell = new Shell($config);
return $shell->run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment