Skip to content

Commit 5ec0e26

Browse files
authored
Merge pull request #12 from usamamuneerchaudhary/master
WordPress Installation Issue on Windows & Removed Vertical Scrollbar from the landing page
2 parents f6c85a4 + b9e6112 commit 5ec0e26

File tree

3 files changed

+42
-35
lines changed

3 files changed

+42
-35
lines changed

src/WPCli.php

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class WPCli
3232
*/
3333
public function __construct(InputInterface $input, OutputInterface $output)
3434
{
35-
$this->input = $input;
35+
$this->input = $input;
3636
$this->output = $output;
3737

3838
// try from local vendor/bin
@@ -43,6 +43,9 @@ public function __construct(InputInterface $input, OutputInterface $output)
4343
$this->wp = dirname(dirname(dirname(__DIR__))) . '/bin/wp';
4444
}
4545

46+
// make it cross-platform
47+
$this->wp = str_replace("/", DIRECTORY_SEPARATOR, $this->wp);
48+
4649
}
4750

4851
/**
@@ -53,10 +56,10 @@ public function __construct(InputInterface $input, OutputInterface $output)
5356
public function config($args = [])
5457
{
5558
$args = $this->parseArgs([
56-
'dbname' => '',
57-
'dbhost' => '',
58-
'dbuser' => '',
59-
'dbpass' => '',
59+
'dbname' => '',
60+
'dbhost' => '',
61+
'dbuser' => '',
62+
'dbpass' => '',
6063
'dbprefix' => 'wp_',
6164
], $args);
6265

@@ -72,7 +75,7 @@ public function parseArgs(array $defaults, array $args)
7275
{
7376
foreach ($args as $key => $value) {
7477
if (!empty($value)) {
75-
$defaults[ $key ] = $value;
78+
$defaults[$key] = $value;
7679
}
7780
}
7881

@@ -88,21 +91,25 @@ public function parseArgs(array $defaults, array $args)
8891
*/
8992
public function execute($command, $args = [])
9093
{
91-
$command = "$this->wp $command ";
94+
$command = sprintf('"%s" %s', $this->wp, $command);
95+
9296
foreach ($args as $arg => $value) {
9397
if (substr($arg, 0, strlen('prompt=')) == 'prompt=') {
94-
$command .= "--$arg ";
98+
$command .= " --$arg ";
9599
continue;
96100
}
97101

98-
$command .= "--$arg='$value' ";
102+
$command .= " --$arg=\"$value\"";
99103
}
100104

101105
$process = new Process($command);
102106
if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
103107
$process->setTty(true);
104108
}
105-
$process->run();
109+
110+
$process->run(function ($type, $line) {
111+
$this->output->writeln($line);
112+
});
106113

107114
return $process;
108115
}
@@ -116,13 +123,13 @@ public function execute($command, $args = [])
116123
public function install($args)
117124
{
118125
$args = $this->parseArgs([
119-
'url' => 'localhost/' . $this->input->getArgument('name'),
120-
'title' => 'Just another WordPress site',
121-
'admin_user' => 'admin',
126+
'url' => 'localhost/' . $this->input->getArgument('name'),
127+
'title' => 'Just another WordPress site',
128+
'admin_user' => 'admin',
122129
'admin_password' => null,
123-
'admin_email' => '',
124-
'skip-email' => false,
125-
'path' => '',
130+
'admin_email' => '',
131+
'skip-email' => false,
132+
'path' => '',
126133
], $args);
127134

128135
return $this->execute('core install', $args);

src/WPInstaller.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ public function __construct(
5959
InputInterface $input,
6060
OutputInterface $output,
6161
WPCli $WPCli
62-
) {
63-
$this->config = $config;
64-
$this->input = $input;
65-
$this->output = $output;
66-
$this->WPCli = $WPCli;
62+
)
63+
{
64+
$this->config = $config;
65+
$this->input = $input;
66+
$this->output = $output;
67+
$this->WPCli = $WPCli;
6768
$this->command = $command;
6869
}
6970

@@ -109,22 +110,22 @@ public function pathToWordPress()
109110
protected function run()
110111
{
111112
$args = [
112-
'url' => $this->input->getOption('url'),
113-
'title' => $this->input->getOption('title'),
114-
'admin_user' => $this->config->get('wp_username'),
113+
'url' => $this->input->getOption('url'),
114+
'title' => $this->input->getOption('title'),
115+
'admin_user' => $this->config->get('wp_username'),
115116
'admin_email' => $this->config->get('email'),
116-
'skip-email' => true,
117-
'path' => $this->input->getArgument('name'),
117+
'skip-email' => true,
118+
'path' => realpath($this->input->getArgument('name')),
118119
];
119120

120121
$this->output->writeln("<comment>Installing WordPress, you'll be asked for admin password which is optional if not provided we'll generate one for you.<comment>");
121122

122123
// ask for admin password and feed it to wp-cli
123-
$helper = $this->command->getHelper('question');
124+
$helper = $this->command->getHelper('question');
124125
$question = new Question('<info>Please enter new password for WordPress admin panel : </info>', null);
125126
$question->setHidden(true);
126127
$question->setHiddenFallback(false);
127-
$args[ 'admin_password' ] = $helper->ask($this->input, $this->output, $question);
128+
$args['admin_password'] = $helper->ask($this->input, $this->output, $question);
128129

129130
$this->WPCli->install($args);
130131

@@ -139,11 +140,11 @@ protected function run()
139140
protected function configure()
140141
{
141142
$this->WPCli->config([
142-
'dbname' => $this->input->getOption('db') ?: $this->input->getArgument('name'),
143-
'dbuser' => $this->config->get('username'),
144-
'dbpass' => $this->config->get('password'),
145-
'dbhost' => $this->config->get('host'),
146-
'path' => $this->input->getArgument('name'),
143+
'dbname' => $this->input->getOption('db') ?: $this->input->getArgument('name'),
144+
'dbuser' => $this->config->get('username'),
145+
'dbpass' => $this->config->get('password'),
146+
'dbhost' => $this->config->get('host'),
147+
'path' => realpath($this->input->getArgument('name')),
147148
'dbprefix' => $this->input->getOption('prefix') ?: $this->input->getArgument('name') . '_',
148149
]);
149150

@@ -178,7 +179,7 @@ protected function createDatabase()
178179
*/
179180
protected function connect()
180181
{
181-
$host = $this->config->get('host');
182+
$host = $this->config->get('host');
182183
$username = $this->config->get('username');
183184
$password = $this->config->get('password');
184185

theme/views/includes/header.twig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
color: #636b6f;
2424
font-family: 'Raleway', sans-serif;
2525
font-weight: 100;
26-
height: 100vh;
2726
margin: 0;
2827
margin-top:8%;
2928
}

0 commit comments

Comments
 (0)