Example #1
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     App::bind('io', new IO($this, $input, $output))->title('Purge');
     $pdo = (require App::get('in')->getArgument('pdo'));
     jp::CleanMsSQLdb($pdo);
     App::get('io')->success("Purged");
 }
Example #2
0
 public function database()
 {
     $name = $this->name;
     $env = App::get('Environment');
     $env = strtoupper(substr($env, 0, 1));
     $id = App::get('id');
     return $name . "_{$env}{$id}";
 }
Example #3
0
 protected function sqlUser(string $username) : string
 {
     $hostname = App::get('Hostname');
     $password = App::get('Random')->password();
     $permission = $this->sqlUserGrant($username);
     file_put_contents("{$username}.pdo.php", new PDOFile(App::get('Name')->database(), $username, $password, $hostname));
     return "\n\t\t\tCREATE USER '{$username}'@'{$hostname}'\n\t\t\tIDENTIFIED BY '{$password}';\n\t\t\t{$permission} TO '{$username}'@'{$hostname}';\n\t\t";
 }
Example #4
0
 public function __construct()
 {
     if (!$this->validate(App::get('in')->getOption('environment'))) {
         $question = new ChoiceQuestion('Do you want a development, test, or production environment?', ['development', 'test', 'production'], 'development');
         $question->setErrorMessage('%s is invalid.');
         $this->validate(App::get('io')->question($question));
     }
     App::get('io')->write("<comment>environment:</> <info>{$this->environment}</>");
 }
Example #5
0
 public function __construct(Command $cmd, InputInterface $in, OutputInterface $out)
 {
     $this->cmd = $cmd;
     $this->in = $in;
     $this->out = $out;
     App::bind('in', $in);
     App::bind('out', $out);
     $this->style = new SymfonyStyle($in, $out);
 }
Example #6
0
 protected function getLogin() : array
 {
     $login['username'] = App::get('io')->ask('What is the privileged username?', 'root');
     $login['password'] = App::get('io')->askHidden('What is the password?', function ($password) {
         if (empty($password)) {
             throw new RuntimeException('Password cannot be empty.');
         }
         return $password;
     });
     return $login;
 }
Example #7
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     App::bind('io', new IO($this, $input, $output))->title('Execute');
     $file = App::get('in')->getArgument('sql');
     $pathinfo = pathinfo($file);
     if ($pathinfo['extension'] === 'sql') {
         $files[] = $file;
     } else {
         $files = file($file, FILE_IGNORE_NEW_LINES);
         // eager load in case of PDOFile path before chdir
         App::get('Query');
         chdir($pathinfo['dirname']);
     }
     foreach ($files as $file) {
         $sql = file_get_contents($file);
         $result = App::get('Query')->execute($sql);
         if ($result !== false) {
             App::get('io')->success("Executed {$file}");
         }
     }
 }