webman有类型laravel tinker的工具吗

hon陈烁临

webman有类型laravel tinker的工具吗

习惯使用laravel tinker 调试代码,webman有没有类似方案?

852 1 0
1个回答

hon陈烁临

消灭0回答

使用 psy/psysh 简单实现一个 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);
        // 通过命令参数传入需要 include的文件路径
        // $shell->setIncludes();

        try {
            $shell->run();
        } finally {
        }
    }
}
  • 暂无评论
年代过于久远,无法发表回答
🔝