InitDependence.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Symfony\Component\Process\Process;
  5. use Symfony\Component\Process\Exception\ProcessFailedException;
  6. class InitDependence extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'init:dep';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'init dependence date - dictionay,pali sencence';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return int
  33. */
  34. public function handle()
  35. {
  36. #克隆依赖的数据到本地
  37. #巴利句子
  38. $git['pali_sentence'] = env('DEPENDENCE_PALI_SENT', 'http://visuddhinanda.github.com/pali_sent/.git');
  39. #巴利相似句
  40. $git['pali_similarity'] = env('DEPENDENCE_PALI_SIM', 'http://visuddhinanda.github.com/pali_sim/.git');
  41. #单词分析
  42. $git['word_statistics'] = env('DEPENDENCE_WORD_STATI', 'http://visuddhinanda.github.com/word_statistics/.git');
  43. foreach ($git as $key => $value) {
  44. # clone repo to local
  45. $process = new Process(['git','clone',$pali_sent,storage_path($key)]);
  46. $process->run();
  47. if(!$process->isSuccessful()){
  48. throw new ProcessFailedException($process);
  49. }
  50. $this->info($process->getOutput());
  51. }
  52. return 0;
  53. }
  54. }