// +---------------------------------------------------------------------- namespace think\console\command\optimize; use think\console\Command; use think\console\Input; use think\console\input\Option; use think\console\Output; use think\Db; class Schema extends Command { /** @var Output */ protected $output; protected function configure() { $this->setName('optimize:schema') ->addOption('table', null, Option::VALUE_REQUIRED, 'Build table schema cache .') ->setDescription('Build database schema cache.'); } protected function execute(Input $input, Output $output) { if ($input->hasOption('table')) { $tables[] = $input->getOption('table'); } else { $tables = Db::getTables(); } if (!is_dir(RUNTIME_PATH . 'schema')) { @mkdir(RUNTIME_PATH . 'schema', 0755, true); } foreach ($tables as $table) { $content = 'writeln('Succeed!'); } }