protected function onExecute($argv = null) { $path = $this->getPath(); if (is_file($path)) { throw new \Exception("The file {$path} is existing!"); } $content = $this->buildClass($this->class); $dir = dirname($path); if (!is_dir($dir)) { mkdir($dir, 0755, true); } if (file_put_contents($path, $content)) { $this->console->println("Add controller '{$this->class}' success!"); $action = $this->web->getDefaultAction(); $command = new NewAction(['', "{$this->name}#{$action}"]); $command->execute(); } else { $this->console->println("Add controller '{$this->class}' lost, please try again."); } }