消滅0回答
使用 psy/psysh 簡(jiǎn)單實(shí)現(xiàn)一個(gè) tinker 命令 ,基本可用。 效果如下:
命令代碼如下:
namespace app\command;
use Psy\Configuration;
use Psy\Shell;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
class Tinker extends Command
{
protected static $defaultName = 'tinker';
protected static $defaultDescription = 'Interact with your application';
/**
* @return void
*/
protected function configure()
{
$this->addArgument('name', InputArgument::OPTIONAL, 'Name description');
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->getApplication()->setCatchExceptions(false);
$config = new Configuration([
'updateCheck' => 'never',
]);
$shell = new Shell($config);
// 通過(guò)命令參數(shù)傳入需要 include的文件路徑
// $shell->setIncludes();
try {
$shell->run();
} finally {
}
}
}