27ca0d23e4917ad7dcc3bb84c36f025ad0c45c52.svn-base 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * 安装composer
  4. */
  5. class Setup
  6. {
  7. protected static $_instance;
  8. public static function getInstance()
  9. {
  10. if(self::$_instance === null)
  11. {
  12. self::$_instance = new self();
  13. }
  14. return self::$_instance;
  15. }
  16. public static function init()
  17. {
  18. //$HOME
  19. $composer = '/bin/composer';
  20. $shell = 'sudo curl -sS https://getcomposer.org/installer | sudo php -d detect_unicode=Off';
  21. system($shell);
  22. $shell = 'sudo mv composer.phar ' . $composer;
  23. system($shell);
  24. $shell = 'sudo chmod +x ' . $composer;
  25. system($shell);
  26. $shell = 'composer install';
  27. system($shell);
  28. }
  29. public static function update()
  30. {
  31. $shell = 'composer update';
  32. system($shell);
  33. }
  34. public static function git()
  35. {
  36. $shell = 'sudo apt-get install git-core';
  37. system($shell);
  38. }
  39. public static function laravel()
  40. {
  41. $shell = 'composer create-project laravel/laravel --prefer-dist';
  42. system($shell);
  43. }
  44. }
  45. echo "请输入命令以执行相应操作:\ninit:初始化\nupdate:更新\ngit:安装git\nlaravel:安装laravel\n在输入命令之后按回车键\n";
  46. $stdin = fopen('php://stdin','r');
  47. $shell = trim(fgets($stdin,100));
  48. switch($shell)
  49. {
  50. case 'init':
  51. Setup::init();
  52. break;
  53. case 'update':
  54. Setup::update();
  55. break;
  56. case 'git':
  57. Setup::git();
  58. break;
  59. case 'laravel':
  60. Setup::laravel();
  61. break;
  62. default:
  63. echo "未定义的方法";
  64. break;
  65. }