diff --git a/cli/ValetPlus/AbstractService.php b/cli/ValetPlus/AbstractService.php index 3447084a..09bd5369 100644 --- a/cli/ValetPlus/AbstractService.php +++ b/cli/ValetPlus/AbstractService.php @@ -6,6 +6,7 @@ use JsonException; use Valet\Brew; +use Valet\CommandLine; use Valet\Configuration; use Valet\Filesystem; @@ -22,6 +23,8 @@ abstract class AbstractService protected $configClassName; /** @var Brew */ protected $brew; + /** @var CommandLine */ + protected $cli; /** @var Filesystem */ protected $files; @@ -29,15 +32,18 @@ abstract class AbstractService * @param Configuration $configuration * @param Brew $brew * @param Filesystem $files + * @param CommandLine $cli */ public function __construct( Configuration $configuration, Brew $brew, - Filesystem $files + Filesystem $files, + CommandLine $cli ) { $this->configuration = $configuration; $this->brew = $brew; $this->files = $files; + $this->cli = $cli; } /** diff --git a/cli/ValetPlus/Extended/Status.php b/cli/ValetPlus/Extended/Status.php index 061ab66e..29f4fc7c 100644 --- a/cli/ValetPlus/Extended/Status.php +++ b/cli/ValetPlus/Extended/Status.php @@ -11,6 +11,9 @@ use Valet\Status as ValetStatus; use WeProvide\ValetPlus\Mailhog; use WeProvide\ValetPlus\Mysql; +use WeProvide\ValetPlus\Rabbitmq; +use WeProvide\ValetPlus\Redis; +use WeProvide\ValetPlus\Varnish; class Status extends ValetStatus { @@ -18,6 +21,12 @@ class Status extends ValetStatus protected $mysql; /** @var Mailhog */ protected $mailhog; + /** @var Varnish */ + protected $varnish; + /** @var Redis */ + protected $redis; + /** @var Rabbitmq */ + protected $rabbitmq; /** * @param Configuration $config @@ -26,6 +35,9 @@ class Status extends ValetStatus * @param Filesystem $files * @param Mysql $mysql * @param Mailhog $mailhog + * @param Varnish $varnish + * @param Redis $redis + * @param Rabbitmq $rabbitmq */ public function __construct( Configuration $config, @@ -33,12 +45,18 @@ public function __construct( CommandLine $cli, Filesystem $files, Mysql $mysql, - Mailhog $mailhog + Mailhog $mailhog, + Varnish $varnish, + Redis $redis, + Rabbitmq $rabbitmq ) { parent::__construct($config, $brew, $cli, $files); - $this->mysql = $mysql; - $this->mailhog = $mailhog; + $this->mysql = $mysql; + $this->mailhog = $mailhog; + $this->varnish = $varnish; + $this->redis = $redis; + $this->rabbitmq = $rabbitmq; } /** @@ -53,20 +71,51 @@ public function checks(): array $mysqlVersion = $this->mysql->installedVersion(); $checks[] = [ - 'description' => '[Valet+] Is Mysql ('.$mysqlVersion.') installed?', + 'description' => '[Valet+] Is Mysql (' . $mysqlVersion . ') installed?', 'check' => function () { return $this->mysql->installedVersion(); }, - 'debug' => 'Run `composer require weprovide/valet-plus` and `valet install`.' + 'debug' => 'Run `composer require weprovide/valet-plus` and `valet-plus install`.' ]; $checks[] = [ 'description' => '[Valet+] Is Mailhog installed?', 'check' => function () { return $this->mailhog->installed(); }, - 'debug' => 'Run `composer require weprovide/valet-plus` and `valet install`.' + 'debug' => 'Run `composer require weprovide/valet-plus` and `valet-plus install`.' ]; + if ($this->varnish->installed() || $this->varnish->isEnabled()) { + $checks[] = [ + 'description' => '[Valet+] Is Varnish installed?', + 'check' => function () { + return $this->varnish->installed() && $this->varnish->isEnabled(); + }, + 'debug' => 'Varnish is installed but not enabled, you might run `valet-plus varnish on`.' + ]; + //todo; actually test something? + } + if ($this->redis->installed() || $this->redis->isEnabled()) { + $checks[] = [ + 'description' => '[Valet+] Is Redis installed?', + 'check' => function () { + return $this->redis->installed() && $this->redis->isEnabled(); + }, + 'debug' => 'Redis is installed but not enabled, you might run `valet-plus redis on`.' + ]; + //todo; actually test something? + } + if ($this->rabbitmq->installed() || $this->rabbitmq->isEnabled()) { + $checks[] = [ + 'description' => '[Valet+] Is Rabbitmq installed?', + 'check' => function () { + return $this->rabbitmq->installed() && $this->rabbitmq->isEnabled(); + }, + 'debug' => 'Rabbitmq is installed but not enabled, you might run `valet-plus rabbitmq on`.' + ]; + //todo; actually test something? + } + return $checks; } } diff --git a/cli/ValetPlus/Mailhog.php b/cli/ValetPlus/Mailhog.php index af9b4ea3..b1344d00 100644 --- a/cli/ValetPlus/Mailhog.php +++ b/cli/ValetPlus/Mailhog.php @@ -25,8 +25,6 @@ class Mailhog extends AbstractService /** @var string */ const NGINX_CONFIGURATION_PATH = VALET_HOME_PATH . '/Nginx/mailhog.conf'; - /** @var CommandLine */ - protected $cli; /** @var EventDispatcher */ protected $eventDispatcher; @@ -42,11 +40,10 @@ public function __construct( Filesystem $files, CommandLine $cli ) { - parent::__construct($configuration, $brew, $files); + parent::__construct($configuration, $brew, $files, $cli); $container = Container::getInstance(); $this->eventDispatcher = $container->get('event_dispatcher'); - $this->cli = $cli; } /** diff --git a/cli/ValetPlus/Rabbitmq.php b/cli/ValetPlus/Rabbitmq.php index ef421774..2d9cf831 100644 --- a/cli/ValetPlus/Rabbitmq.php +++ b/cli/ValetPlus/Rabbitmq.php @@ -52,7 +52,9 @@ public function restart(): void return; } - $this->brew->restartService(static::SERVICE_NAME); + $this->brew->stopService(static::SERVICE_NAME); + info("Starting " . static::SERVICE_NAME . "..."); + $this->cli->quietlyAsUser('brew services restart ' . static::SERVICE_NAME); } /**