Last active
March 1, 2021 20:57
-
-
Save Nex-Otaku/705474874c9957a85912be76b184e34f to your computer and use it in GitHub Desktop.
REPL shell command draft for Yii 3 application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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