-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
86 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,23 @@ | |
|
||
namespace Zenstruck\PMA\Server\Command; | ||
|
||
use Symfony\Bundle\WebServerBundle\WebServerConfig; | ||
use Symfony\Component\Console\Command\Command; | ||
|
||
/** | ||
* @author Kevin Bond <[email protected]> | ||
*/ | ||
abstract class BaseCommand extends Command | ||
{ | ||
protected function webserverConfig(): WebServerConfig | ||
{ | ||
if (!\file_exists($address = $this->addressFile()) || !\file_exists($router = $this->routerFile())) { | ||
throw new \RuntimeException('phpMyAdmin not initialized. Run "phpmyadmin init".'); | ||
} | ||
|
||
return new WebServerConfig($this->documentRoot(), 'dev', \file_get_contents($address), $router); | ||
} | ||
|
||
protected function folderName(): string | ||
{ | ||
return 'phpmyadmin-server'; | ||
|
@@ -33,4 +43,9 @@ protected function routerFile(): string | |
{ | ||
return "{$this->documentRoot()}/.router.php"; | ||
} | ||
|
||
protected function pidFile(): string | ||
{ | ||
return $this->documentRoot().'/.pid'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Zenstruck\PMA\Server\Command; | ||
|
||
use Symfony\Bundle\WebServerBundle\WebServer; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
/** | ||
* @author Kevin Bond <[email protected]> | ||
*/ | ||
final class StatusCommand extends BaseCommand | ||
{ | ||
protected function configure(): void | ||
{ | ||
$this | ||
->setName('status') | ||
->setDescription('Check the status of the phpMyAdmin server') | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new SymfonyStyle($input, $output); | ||
$server = new WebServer(); | ||
$config = $this->webserverConfig(); | ||
|
||
if ($server->isRunning($this->pidFile())) { | ||
$io->success(\sprintf('phpMyAdmin web server is running (http://%s).', $config->getAddress())); | ||
|
||
return 0; | ||
} | ||
|
||
$io->warning('phpMyAdmin web server is NOT running.'); | ||
|
||
return 1; | ||
} | ||
} |