Build.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. use think\facade\App;
  17. use think\facade\Build as AppBuild;
  18. class Build extends Command
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. protected function configure()
  24. {
  25. $this->setName('build')
  26. ->setDefinition([
  27. new Option('config', null, Option::VALUE_OPTIONAL, "build.php path"),
  28. new Option('module', null, Option::VALUE_OPTIONAL, "module name"),
  29. ])
  30. ->setDescription('Build Application Dirs');
  31. }
  32. protected function execute(Input $input, Output $output)
  33. {
  34. if ($input->hasOption('module')) {
  35. AppBuild::module($input->getOption('module'));
  36. $output->writeln("Successed");
  37. return;
  38. }
  39. if ($input->hasOption('config')) {
  40. $build = include $input->getOption('config');
  41. } else {
  42. $build = include App::getAppPath() . 'build.php';
  43. }
  44. if (empty($build)) {
  45. $output->writeln("Build Config Is Empty");
  46. return;
  47. }
  48. AppBuild::run($build);
  49. $output->writeln("Successed");
  50. }
  51. }