|
@@ -84,20 +84,20 @@ discard block |
|
|
block discarded – undo |
|
84
|
84
|
$this->output->writeln('Now, we need to find the root of your web application.'); |
|
85
|
85
|
$appDirectory = $this->getAentHelper()->question('PHP application root directory (relative to the project root directory)') |
|
86
|
86
|
->setHelpText('Your PHP application root directory is typically the directory that contains your composer.json file. It must be relative to the project root directory.') |
|
87
|
|
- ->setValidator(function (string $appDirectory) { |
|
|
87
|
+ ->setValidator(function(string $appDirectory) { |
|
88
|
88
|
$appDirectory = trim($appDirectory, '/') ?: '.'; |
|
89
|
89
|
$rootDir = Pheromone::getContainerProjectDirectory(); |
|
90
|
90
|
|
|
91
|
|
- $fullDir = $rootDir.'/'.$appDirectory; |
|
|
91
|
+ $fullDir = $rootDir . '/' . $appDirectory; |
|
92
|
92
|
if (!is_dir($fullDir)) { |
|
93
|
|
- throw new \InvalidArgumentException('Could not find directory '.Pheromone::getHostProjectDirectory().'/'.$appDirectory); |
|
|
93
|
+ throw new \InvalidArgumentException('Could not find directory ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory); |
|
94
|
94
|
} |
|
95
|
95
|
return $appDirectory; |
|
96
|
96
|
})->ask(); |
|
97
|
97
|
|
|
98
|
|
- $this->output->writeln('<info>Your root PHP application directory is '.Pheromone::getHostProjectDirectory().'/'.$appDirectory.'</info>'); |
|
|
98
|
+ $this->output->writeln('<info>Your root PHP application directory is ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . '</info>'); |
|
99
|
99
|
|
|
100
|
|
- $service->addBindVolume('./'.$appDirectory, '/var/www/html'); |
|
|
100
|
+ $service->addBindVolume('./' . $appDirectory, '/var/www/html'); |
|
101
|
101
|
|
|
102
|
102
|
/************************ Web application path **********************/ |
|
103
|
103
|
if ($variant === 'apache') { |
|
@@ -105,19 +105,19 @@ discard block |
|
|
block discarded – undo |
|
105
|
105
|
->yesNoQuestion()->setDefault('y')->ask(); |
|
106
|
106
|
if ($answer) { |
|
107
|
107
|
$webDirectory = $this->getAentHelper()->question('Web directory (relative to the PHP application directory)') |
|
108
|
|
- ->setHelpText('Your PHP application web directory is typically the directory that contains your index.php file. It must be relative to the PHP application directory ('.Pheromone::getHostProjectDirectory().'/'.$appDirectory.')') |
|
109
|
|
- ->setValidator(function (string $webDirectory) use ($appDirectory) { |
|
|
108
|
+ ->setHelpText('Your PHP application web directory is typically the directory that contains your index.php file. It must be relative to the PHP application directory (' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . ')') |
|
|
109
|
+ ->setValidator(function(string $webDirectory) use ($appDirectory) { |
|
110
|
110
|
$webDirectory = trim($webDirectory, '/') ?: '.'; |
|
111
|
111
|
$rootDir = Pheromone::getContainerProjectDirectory(); |
|
112
|
112
|
|
|
113
|
|
- $fullDir = $rootDir.'/'.$appDirectory.'/'.$webDirectory; |
|
|
113
|
+ $fullDir = $rootDir . '/' . $appDirectory . '/' . $webDirectory; |
|
114
|
114
|
if (!is_dir($fullDir)) { |
|
115
|
|
- throw new \InvalidArgumentException('Could not find directory '.Pheromone::getHostProjectDirectory().'/'.$appDirectory.'/'.$webDirectory); |
|
|
115
|
+ throw new \InvalidArgumentException('Could not find directory ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . '/' . $webDirectory); |
|
116
|
116
|
} |
|
117
|
117
|
return $webDirectory; |
|
118
|
118
|
})->ask(); |
|
119
|
119
|
$service->addImageEnvVariable('APACHE_DOCUMENT_ROOT', $webDirectory); |
|
120
|
|
- $this->output->writeln('<info>Your web directory is '.Pheromone::getHostProjectDirectory().'/'.$appDirectory.'/'.$webDirectory.'</info>'); |
|
|
120
|
+ $this->output->writeln('<info>Your web directory is ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . '/' . $webDirectory . '</info>'); |
|
121
|
121
|
} |
|
122
|
122
|
} |
|
123
|
123
|
|
|
@@ -135,19 +135,19 @@ discard block |
|
|
block discarded – undo |
|
135
|
135
|
$uploadDirectory = trim($uploadDirectory, '/'); |
|
136
|
136
|
$rootDir = Pheromone::getContainerProjectDirectory(); |
|
137
|
137
|
if ($uploadDirectory !== '') { |
|
138
|
|
- $fullDir = $rootDir.'/'.$appDirectory.'/'.$uploadDirectory; |
|
|
138
|
+ $fullDir = $rootDir . '/' . $appDirectory . '/' . $uploadDirectory; |
|
139
|
139
|
if (!is_dir($fullDir)) { |
|
140
|
|
- $this->output->writeln('<error>Could not find directory '.Pheromone::getHostProjectDirectory().'/'.$appDirectory.'/'.$uploadDirectory.'</error>'); |
|
|
140
|
+ $this->output->writeln('<error>Could not find directory ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . '/' . $uploadDirectory . '</error>'); |
|
141
|
141
|
$uploadDirectory = null; |
|
142
|
142
|
} else { |
|
143
|
143
|
$uploadDirs[] = $uploadDirectory; |
|
144
|
|
- $this->output->writeln('<info>Directory '.Pheromone::getHostProjectDirectory().'/'.$appDirectory.'/'.$uploadDirectory.' will be stored out of the container</info>'); |
|
|
144
|
+ $this->output->writeln('<info>Directory ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . '/' . $uploadDirectory . ' will be stored out of the container</info>'); |
|
145
|
145
|
|
|
146
|
146
|
$volumeName = $this->getAentHelper() |
|
147
|
147
|
->question('Please input directory (for instance for file uploads) that you want to mount out of the container? (keep empty to ignore)') |
|
148
|
148
|
->setDefault('') |
|
149
|
149
|
->compulsory() |
|
150
|
|
- ->setValidator(function (string $value) { |
|
|
150
|
+ ->setValidator(function(string $value) { |
|
151
|
151
|
$value = trim($value); |
|
152
|
152
|
if (!\preg_match('/^[a-zA-Z0-9_.-]+$/', $value)) { |
|
153
|
153
|
throw new \InvalidArgumentException('Invalid volume name "' . $value . '". Volume names can contain alphanumeric characters, and "_", ".", "-".'); |
|
@@ -156,14 +156,14 @@ discard block |
|
|
block discarded – undo |
|
156
|
156
|
}) |
|
157
|
157
|
->ask(); |
|
158
|
158
|
$question = new Question('What name should we use for this volume? ', ''); |
|
159
|
|
- $question->setValidator(function (string $value) { |
|
|
159
|
+ $question->setValidator(function(string $value) { |
|
160
|
160
|
$value = trim($value); |
|
161
|
161
|
if (!\preg_match('/^[a-zA-Z0-9_.-]+$/', $value)) { |
|
162
|
|
- throw new \InvalidArgumentException('Invalid volume name "'.$value.'". Volume names can contain alphanumeric characters, and "_", ".", "-".'); |
|
|
162
|
+ throw new \InvalidArgumentException('Invalid volume name "' . $value . '". Volume names can contain alphanumeric characters, and "_", ".", "-".'); |
|
163
|
163
|
} |
|
164
|
164
|
return $value; |
|
165
|
165
|
}); |
|
166
|
|
- $service->addNamedVolume($volumeName, $appDirectory.'/'.$uploadDirectory); |
|
|
166
|
+ $service->addNamedVolume($volumeName, $appDirectory . '/' . $uploadDirectory); |
|
167
|
167
|
} |
|
168
|
168
|
} |
|
169
|
169
|
} while ($uploadDirectory !== ''); |
|
@@ -176,35 +176,35 @@ discard block |
|
|
block discarded – undo |
|
176
|
176
|
$this->output->writeln('By default, the following extensions are enabled:'); |
|
177
|
177
|
$this->output->writeln('<info>apcu mysqli opcache pdo pdo_mysql redis zip soap mbstring ftp mysqlnd</info>'); |
|
178
|
178
|
$this->output->writeln('You can select more extensions below:'); |
|
179
|
|
- $this->output->writeln('<info>'.\implode(' ', $availableExtensions).'</info>'); |
|
|
179
|
+ $this->output->writeln('<info>' . \implode(' ', $availableExtensions) . '</info>'); |
|
180
|
180
|
|
|
181
|
181
|
/************************ Extensions **********************/ |
|
182
|
182
|
$extensions = []; |
|
183
|
183
|
do { |
|
184
|
184
|
$question = new Question('Please enter the name of an additional extension you want to install (keep empty to skip): ', ''); |
|
185
|
185
|
$question->setAutocompleterValues($availableExtensions); |
|
186
|
|
- $question->setValidator(function (string $value) use ($availableExtensions) { |
|
|
186
|
+ $question->setValidator(function(string $value) use ($availableExtensions) { |
|
187
|
187
|
if (trim($value) !== '' && !\in_array($value, $availableExtensions)) { |
|
188
|
|
- throw new \InvalidArgumentException('Unknown extension '.$value); |
|
|
188
|
+ throw new \InvalidArgumentException('Unknown extension ' . $value); |
|
189
|
189
|
} |
|
190
|
190
|
return trim($value); |
|
191
|
191
|
}); |
|
192
|
192
|
$extension = $this->getHelper('question')->ask($this->input, $this->output, $question); |
|
193
|
193
|
if ($extension !== '') { |
|
194
|
|
- $service->addImageEnvVariable('PHP_EXTENSION_'.\strtoupper($extension), '1'); |
|
|
194
|
+ $service->addImageEnvVariable('PHP_EXTENSION_' . \strtoupper($extension), '1'); |
|
195
|
195
|
$extensions[] = $extension; |
|
196
|
196
|
} |
|
197
|
197
|
} while ($extension !== ''); |
|
198
|
|
- $this->output->writeln('<info>Enabled extensions: apcu mysqli opcache pdo pdo_mysql redis zip soap mbstring ftp mysqlnd '.\implode(' ', $extensions).'</info>'); |
|
|
198
|
+ $this->output->writeln('<info>Enabled extensions: apcu mysqli opcache pdo pdo_mysql redis zip soap mbstring ftp mysqlnd ' . \implode(' ', $extensions) . '</info>'); |
|
199
|
199
|
|
|
200
|
200
|
/************************ php.ini settings **********************/ |
|
201
|
201
|
$this->output->writeln("Now, let's customize some settings of <info>php.ini</info>."); |
|
202
|
202
|
|
|
203
|
203
|
$memoryLimit = $this->getAentHelper()->question('PHP <info>memory limit</info> (keep empty to stay with the default 128M)') |
|
204
|
204
|
->setHelpText('This value will be used in the memory_limit option of PHP via the PHP_INI_MEMORY_LIMIT environment variable.') |
|
205
|
|
- ->setValidator(function (string $value) { |
|
|
205
|
+ ->setValidator(function(string $value) { |
|
206
|
206
|
if (trim($value) !== '' && !\preg_match('/^[0-9]+([MGK])?$/i', $value)) { |
|
207
|
|
- throw new \InvalidArgumentException('Invalid value: '.$value); |
|
|
207
|
+ throw new \InvalidArgumentException('Invalid value: ' . $value); |
|
208
|
208
|
} |
|
209
|
209
|
return trim($value); |
|
210
|
210
|
}) |
|
@@ -216,9 +216,9 @@ discard block |
|
|
block discarded – undo |
|
216
|
216
|
|
|
217
|
217
|
$uploadMaxFileSize = $this->getAentHelper()->question('<info>Maximum file size for uploaded files</info> (keep empty to stay with the default 2M)') |
|
218
|
218
|
->setHelpText('This value will be used in the upload_max_file_size and post_max_size options of PHP via the PHP_INI_UPLOAD_MAX_FILESIZE and PHP_INI_POST_MAX_SIZE environment variables.') |
|
219
|
|
- ->setValidator(function (string $value) { |
|
|
219
|
+ ->setValidator(function(string $value) { |
|
220
|
220
|
if (trim($value) !== '' && !\preg_match('/^[0-9]+([MGK])?$/i', $value)) { |
|
221
|
|
- throw new \InvalidArgumentException('Invalid value: '.$value); |
|
|
221
|
+ throw new \InvalidArgumentException('Invalid value: ' . $value); |
|
222
|
222
|
} |
|
223
|
223
|
return trim($value); |
|
224
|
224
|
}) |
|
@@ -238,7 +238,7 @@ discard block |
|
|
block discarded – undo |
|
238
|
238
|
->ask(); |
|
239
|
239
|
if ($depend !== '') { |
|
240
|
240
|
$service->addDependsOn($depend); |
|
241
|
|
- $this->output->writeln('<info>Added dependency: '.$depend.'</info>'); |
|
|
241
|
+ $this->output->writeln('<info>Added dependency: ' . $depend . '</info>'); |
|
242
|
242
|
} |
|
243
|
243
|
} while ($depend !== ''); |
|
244
|
244
|
|