5 * Contains \Drupal\Console\Command\Database\ClientCommand.
8 namespace Drupal\Console\Command\Database;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Symfony\Component\Process\ProcessBuilder;
14 use Drupal\Console\Core\Command\Command;
15 use Drupal\Console\Command\Shared\ConnectTrait;
17 class ClientCommand extends Command
24 protected function configure()
27 ->setName('database:client')
28 ->setDescription($this->trans('commands.database.client.description'))
31 InputArgument::OPTIONAL,
32 $this->trans('commands.database.client.arguments.database'),
35 ->setHelp($this->trans('commands.database.client.help'))
36 ->setAliases(['dbc']);
42 protected function execute(InputInterface $input, OutputInterface $output)
44 $database = $input->getArgument('database');
45 $learning = $input->getOption('learning');
47 $databaseConnection = $this->resolveConnection($database);
49 $connection = sprintf(
50 '%s -A --database=%s --user=%s --password=%s --host=%s --port=%s',
51 $databaseConnection['driver'],
52 $databaseConnection['database'],
53 $databaseConnection['username'],
54 $databaseConnection['password'],
55 $databaseConnection['host'],
56 $databaseConnection['port']
60 $this->getIo()->commentBlock(
62 $this->trans('commands.database.client.messages.connection'),
68 $processBuilder = new ProcessBuilder([]);
69 $processBuilder->setArguments(explode(' ', $connection));
70 $process = $processBuilder->getProcess();
71 $process->setTty('true');
74 if (!$process->isSuccessful()) {
75 throw new \RuntimeException($process->getErrorOutput());