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.

79 lines
1.8 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
  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\Menus\StylesFactory;
  10. use App\Helpers\NginxTemplateHelper;
  11. use App\Menus\Nginx\TemplateMenuFactory;
  12. /**
  13. * Add and Edit Configurations of Vhosts from Nginx
  14. *
  15. * Using php-school/cli-menu
  16. *
  17. * @author Björn Hase, Tentakelfabrik
  18. * @license http://opensource.org/licenses/MIT The MIT License
  19. * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
  20. *
  21. */
  22. class NginxVhostsCommand extends Command
  23. {
  24. // index for vhosts
  25. // @TODO move this in a global class
  26. const VHOST_INDEX = 0;
  27. /**
  28. * The signature of the command.
  29. *
  30. * @var string
  31. */
  32. protected $signature = 'nginx:vhosts';
  33. /**
  34. * The description of the command.
  35. *
  36. * @var string
  37. */
  38. protected $description = 'Create and Manage Nginx Vhosts';
  39. /**
  40. * let it rain
  41. *
  42. *
  43. */
  44. public function handle()
  45. {
  46. $nginxTemplateHelper = new TemplateMenuFactory();
  47. // create menu
  48. $builder = $this->menu('Nginx')
  49. // add Submenu for select templates
  50. ->addLineBreak('-')
  51. ->addSubMenu('Add', $nginxTemplateHelper->addSelectTemplateItem());
  52. $builder->addLineBreak('-');
  53. // apperance
  54. $builder = StylesFactory::setMenuStyles($builder);
  55. $mainmenu = $builder->build();
  56. // remove first item
  57. $items = $mainmenu->getItems();
  58. unset($items[0]);
  59. $mainmenu->setItems($items);
  60. // adding current vhosts
  61. $mainmenu = NginxVhostFactory::addVhosts($mainmenu, NginxVhost::find(), self::VHOST_INDEX);
  62. $mainmenu->open();
  63. }
  64. }