OpenSource CLI-App to install and handle stuff related to Web-Server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.1 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\Commands;
  3. use Illuminate\Console\Scheduling\Schedule;
  4. use LaravelZero\Framework\Commands\Command;
  5. use Illuminate\Support\Facades\File;
  6. use App\Facades\Install;
  7. use App\Facades\NginxVhost;
  8. use App\Facades\NginxVhostFactory;
  9. use App\Facades\TerminalHelper;
  10. use App\Facades\Menus\StylesFactory;
  11. use App\Helpers\NginxTemplateHelper;
  12. use App\Menus\Nginx\NginxVhostGoBackAction;
  13. use App\Menus\Nginx\TemplateMenuFactory;
  14. use PhpSchool\CliMenu\Builder\CliMenuBuilder;
  15. use PhpSchool\CliMenu\CliMenu;
  16. use PhpSchool\CliMenu\MenuItem\CheckboxItem;
  17. use PhpSchool\CliMenu\Style\SelectableStyle;
  18. use PhpSchool\CliMenu\MenuItem\MenuMenuItem;
  19. /**
  20. * Add and Edit Configurations of Vhosts from Nginx
  21. *
  22. * Using php-school/cli-menu
  23. *
  24. * @author Björn Hase, Tentakelfabrik
  25. * @license http://opensource.org/licenses/MIT The MIT License
  26. * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
  27. *
  28. */
  29. class NginxVhostsCommand extends Command
  30. {
  31. // index for vhosts
  32. // @TODO move this in a global class
  33. const VHOST_INDEX = 0;
  34. /**
  35. * The signature of the command.
  36. *
  37. * @var string
  38. */
  39. protected $signature = 'nginx:vhosts';
  40. /**
  41. * The description of the command.
  42. *
  43. * @var string
  44. */
  45. protected $description = 'Create and Manage Nginx Vhosts';
  46. /**
  47. * let it rain
  48. *
  49. *
  50. */
  51. public function handle()
  52. {
  53. $nginxTemplateHelper = new TemplateMenuFactory();
  54. // create menu
  55. $builder = $this->menu('Nginx')
  56. // add Submenu for select templates
  57. ->addLineBreak('-')
  58. ->addSubMenu('Add', $nginxTemplateHelper->addSelectTemplateItem());
  59. $builder->addLineBreak('-');
  60. // apperance
  61. $builder = StylesFactory::setMenuStyles($builder);
  62. $mainmenu = $builder->build();
  63. // remove first item
  64. $items = $mainmenu->getItems();
  65. unset($items[0]);
  66. $mainmenu->setItems($items);
  67. // adding current vhosts
  68. $mainmenu = NginxVhostFactory::addVhosts($mainmenu, NginxVhost::find(), self::VHOST_INDEX);
  69. $mainmenu->open();
  70. }
  71. }