Build.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: yunwuxin <448901948@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace think\console\command;
  12. use think\console\Command;
  13. use think\console\Input;
  14. use think\console\input\Option;
  15. use think\console\Output;
  16. class Build extends Command
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. protected function configure()
  22. {
  23. $this->setName('build')
  24. ->setDefinition([
  25. new Option('config', null, Option::VALUE_OPTIONAL, "build.php path"),
  26. new Option('module', null, Option::VALUE_OPTIONAL, "module name"),
  27. ])
  28. ->setDescription('Build Application Dirs');
  29. }
  30. protected function execute(Input $input, Output $output)
  31. {
  32. if ($input->hasOption('module')) {
  33. \think\Build::module($input->getOption('module'));
  34. $output->writeln("Successed");
  35. return;
  36. }
  37. if ($input->hasOption('config')) {
  38. $build = include $input->getOption('config');
  39. } else {
  40. $build = include APP_PATH . 'build.php';
  41. }
  42. if (empty($build)) {
  43. $output->writeln("Build Config Is Empty");
  44. return;
  45. }
  46. \think\Build::run($build);
  47. $output->writeln("Successed");
  48. }
  49. }