github.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php namespace Laravel\CLI\Tasks\Bundle\Providers;
  2. use Laravel\Request;
  3. class Github extends Provider {
  4. /**
  5. * Install the given bundle into the application.
  6. *
  7. * @param string $bundle
  8. * @return void
  9. */
  10. public function install($bundle)
  11. {
  12. $method = (Request::server('cli.zip')) ? 'zipball' : 'submodule';
  13. $this->$method($bundle);
  14. }
  15. /**
  16. * Install a Github hosted bundle from Zip.
  17. *
  18. * @param string $bundle
  19. * @return void
  20. */
  21. protected function zipball($bundle)
  22. {
  23. $url = "http://nodeload.github.com/{$bundle['location']}/zipball/master";
  24. parent::zipball($bundle, $url, true);
  25. echo "Bundle [{$bundle['name']}] has been installed!".PHP_EOL;
  26. }
  27. /**
  28. * Install a Github hosted bundle using submodules.
  29. *
  30. * @param string $bundle
  31. * @return void
  32. */
  33. protected function submodule($bundle)
  34. {
  35. $repository = "git@github.com:{$bundle['location']}.git";
  36. $this->directory($bundle);
  37. // We need to just extract the basename of the bundle path when
  38. // adding the submodule. Of course, we can't add a submodule to
  39. // a location outside of the Git repository, so we don't need
  40. // the full bundle path.
  41. $root = basename(path('bundle')).'/';
  42. passthru('git submodule add '.$repository.' '.$root.$this->path($bundle));
  43. passthru('git submodule update');
  44. }
  45. }