|
@@ -82,7 +82,7 @@ discard block |
|
|
block discarded – undo |
|
82
|
82
|
if ($node === 'No') { |
|
83
|
83
|
$node = ''; |
|
84
|
84
|
} else { |
|
85
|
|
- $node = '-'.$node; |
|
|
85
|
+ $node = '-' . $node; |
|
86
|
86
|
} |
|
87
|
87
|
|
|
88
|
88
|
$service->setImage("thecodingmachine/php:$phpVersion-v1-$variant$node"); |
|
@@ -93,22 +93,22 @@ discard block |
|
|
block discarded – undo |
|
93
|
93
|
$this->output->writeln('Now, we need to find the root of your web application.'); |
|
94
|
94
|
$appDirectory = $aentHelper->question('PHP application root directory (relative to the project root directory)') |
|
95
|
95
|
->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.') |
|
96
|
|
- ->setValidator(function (string $appDirectory) { |
|
|
96
|
+ ->setValidator(function(string $appDirectory) { |
|
97
|
97
|
$appDirectory = trim($appDirectory, '/') ?: '.'; |
|
98
|
98
|
$rootDir = Pheromone::getContainerProjectDirectory(); |
|
99
|
99
|
|
|
100
|
|
- $fullDir = $rootDir.'/'.$appDirectory; |
|
|
100
|
+ $fullDir = $rootDir . '/' . $appDirectory; |
|
101
|
101
|
if (!is_dir($fullDir)) { |
|
102
|
|
- throw new \InvalidArgumentException('Could not find directory '.Pheromone::getHostProjectDirectory().'/'.$appDirectory); |
|
|
102
|
+ throw new \InvalidArgumentException('Could not find directory ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory); |
|
103
|
103
|
} |
|
104
|
104
|
return $appDirectory; |
|
105
|
105
|
})->ask(); |
|
106
|
106
|
|
|
107
|
|
- $this->output->writeln('<info>Your root PHP application directory is '.Pheromone::getHostProjectDirectory().'/'.$appDirectory.'</info>'); |
|
|
107
|
+ $this->output->writeln('<info>Your root PHP application directory is ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . '</info>'); |
|
108
|
108
|
$aentHelper->spacer(); |
|
109
|
109
|
$aentHelper->spacer(); |
|
110
|
110
|
|
|
111
|
|
- $service->addBindVolume('./'.$appDirectory, '/var/www/html'); |
|
|
111
|
+ $service->addBindVolume('./' . $appDirectory, '/var/www/html'); |
|
112
|
112
|
|
|
113
|
113
|
/************************ Web application path **********************/ |
|
114
|
114
|
if ($variant === 'apache') { |
|
@@ -116,20 +116,20 @@ discard block |
|
|
block discarded – undo |
|
116
|
116
|
->yesNoQuestion()->setDefault('y')->ask(); |
|
117
|
117
|
if ($answer) { |
|
118
|
118
|
$webDirectory = $aentHelper->question('Web directory (relative to the PHP application directory)') |
|
119
|
|
- ->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.')') |
|
120
|
|
- ->setValidator(function (string $webDirectory) use ($appDirectory) { |
|
|
119
|
+ ->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 . ')') |
|
|
120
|
+ ->setValidator(function(string $webDirectory) use ($appDirectory) { |
|
121
|
121
|
$webDirectory = trim($webDirectory, '/') ?: '.'; |
|
122
|
122
|
$rootDir = Pheromone::getContainerProjectDirectory(); |
|
123
|
123
|
|
|
124
|
|
- $fullDir = $rootDir.'/'.$appDirectory.'/'.$webDirectory; |
|
|
124
|
+ $fullDir = $rootDir . '/' . $appDirectory . '/' . $webDirectory; |
|
125
|
125
|
if (!is_dir($fullDir)) { |
|
126
|
|
- throw new \InvalidArgumentException('Could not find directory '.Pheromone::getHostProjectDirectory().'/'.$appDirectory.'/'.$webDirectory); |
|
|
126
|
+ throw new \InvalidArgumentException('Could not find directory ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . '/' . $webDirectory); |
|
127
|
127
|
} |
|
128
|
128
|
return $webDirectory; |
|
129
|
129
|
})->ask(); |
|
130
|
130
|
|
|
131
|
131
|
$service->addImageEnvVariable('APACHE_DOCUMENT_ROOT', $webDirectory); |
|
132
|
|
- $this->output->writeln('<info>Your web directory is '.Pheromone::getHostProjectDirectory().'/'.$appDirectory.'/'.$webDirectory.'</info>'); |
|
|
132
|
+ $this->output->writeln('<info>Your web directory is ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . '/' . $webDirectory . '</info>'); |
|
133
|
133
|
$aentHelper->spacer(); |
|
134
|
134
|
$aentHelper->spacer(); |
|
135
|
135
|
} |
|
@@ -150,26 +150,26 @@ discard block |
|
|
block discarded – undo |
|
150
|
150
|
$rootDir = Pheromone::getContainerProjectDirectory(); |
|
151
|
151
|
|
|
152
|
152
|
if ($uploadDirectory !== '') { |
|
153
|
|
- $fullDir = $rootDir.'/'.$appDirectory.'/'.$uploadDirectory; |
|
|
153
|
+ $fullDir = $rootDir . '/' . $appDirectory . '/' . $uploadDirectory; |
|
154
|
154
|
if (!is_dir($fullDir)) { |
|
155
|
|
- $this->output->writeln('<error>Could not find directory '.Pheromone::getHostProjectDirectory().'/'.$appDirectory.'/'.$uploadDirectory.'</error>'); |
|
|
155
|
+ $this->output->writeln('<error>Could not find directory ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . '/' . $uploadDirectory . '</error>'); |
|
156
|
156
|
$uploadDirectory = null; |
|
157
|
157
|
} else { |
|
158
|
158
|
$uploadDirs[] = $uploadDirectory; |
|
159
|
|
- $this->output->writeln('<info>Directory '.Pheromone::getHostProjectDirectory().'/'.$appDirectory.'/'.$uploadDirectory.' will be stored out of the container</info>'); |
|
|
159
|
+ $this->output->writeln('<info>Directory ' . Pheromone::getHostProjectDirectory() . '/' . $appDirectory . '/' . $uploadDirectory . ' will be stored out of the container</info>'); |
|
160
|
160
|
|
|
161
|
161
|
$question = new Question('What name should we use for this volume? ', ''); |
|
162
|
|
- $question->setValidator(function (string $value) { |
|
|
162
|
+ $question->setValidator(function(string $value) { |
|
163
|
163
|
$value = trim($value); |
|
164
|
164
|
if (!\preg_match('/^[a-zA-Z0-9_.-]+$/', $value)) { |
|
165
|
|
- throw new \InvalidArgumentException('Invalid volume name "'.$value.'". Volume names can contain alphanumeric characters, and "_", ".", "-".'); |
|
|
165
|
+ throw new \InvalidArgumentException('Invalid volume name "' . $value . '". Volume names can contain alphanumeric characters, and "_", ".", "-".'); |
|
166
|
166
|
} |
|
167
|
167
|
|
|
168
|
168
|
return $value; |
|
169
|
169
|
}); |
|
170
|
170
|
$volumeName = $helper->ask($this->input, $this->output, $question); |
|
171
|
171
|
|
|
172
|
|
- $service->addNamedVolume($volumeName, $appDirectory.'/'.$uploadDirectory); |
|
|
172
|
+ $service->addNamedVolume($volumeName, $appDirectory . '/' . $uploadDirectory); |
|
173
|
173
|
} |
|
174
|
174
|
} |
|
175
|
175
|
} while ($uploadDirectory !== ''); |
|
@@ -184,16 +184,16 @@ discard block |
|
|
block discarded – undo |
|
184
|
184
|
$this->output->writeln('By default, the following extensions are enabled:'); |
|
185
|
185
|
$this->output->writeln('<info>apcu mysqli opcache pdo pdo_mysql redis zip soap mbstring ftp mysqlnd</info>'); |
|
186
|
186
|
$this->output->writeln('You can select more extensions below:'); |
|
187
|
|
- $this->output->writeln('<info>'.\implode(' ', $availableExtensions).'</info>'); |
|
|
187
|
+ $this->output->writeln('<info>' . \implode(' ', $availableExtensions) . '</info>'); |
|
188
|
188
|
|
|
189
|
189
|
/************************ Extensions **********************/ |
|
190
|
190
|
$extensions = []; |
|
191
|
191
|
do { |
|
192
|
192
|
$question = new Question('Please enter the name of an additional extension you want to install (keep empty to skip): ', ''); |
|
193
|
193
|
$question->setAutocompleterValues($availableExtensions); |
|
194
|
|
- $question->setValidator(function (string $value) use ($availableExtensions) { |
|
|
194
|
+ $question->setValidator(function(string $value) use ($availableExtensions) { |
|
195
|
195
|
if (trim($value) !== '' && !\in_array($value, $availableExtensions)) { |
|
196
|
|
- throw new \InvalidArgumentException('Unknown extension '.$value); |
|
|
196
|
+ throw new \InvalidArgumentException('Unknown extension ' . $value); |
|
197
|
197
|
} |
|
198
|
198
|
|
|
199
|
199
|
return trim($value); |
|
@@ -202,11 +202,11 @@ discard block |
|
|
block discarded – undo |
|
202
|
202
|
$extension = $helper->ask($this->input, $this->output, $question); |
|
203
|
203
|
|
|
204
|
204
|
if ($extension !== '') { |
|
205
|
|
- $service->addImageEnvVariable('PHP_EXTENSION_'.\strtoupper($extension), '1'); |
|
|
205
|
+ $service->addImageEnvVariable('PHP_EXTENSION_' . \strtoupper($extension), '1'); |
|
206
|
206
|
$extensions[] = $extension; |
|
207
|
207
|
} |
|
208
|
208
|
} while ($extension !== ''); |
|
209
|
|
- $this->output->writeln('<info>Enabled extensions: apcu mysqli opcache pdo pdo_mysql redis zip soap mbstring ftp mysqlnd '.\implode(' ', $extensions).'</info>'); |
|
|
209
|
+ $this->output->writeln('<info>Enabled extensions: apcu mysqli opcache pdo pdo_mysql redis zip soap mbstring ftp mysqlnd ' . \implode(' ', $extensions) . '</info>'); |
|
210
|
210
|
$aentHelper->spacer(); |
|
211
|
211
|
$aentHelper->spacer(); |
|
212
|
212
|
|
|
@@ -216,9 +216,9 @@ discard block |
|
|
block discarded – undo |
|
216
|
216
|
|
|
217
|
217
|
$memoryLimit = $aentHelper->question('PHP <info>memory limit</info> (keep empty to stay with the default 128M)') |
|
218
|
218
|
->setHelpText('This value will be used in the memory_limit option of PHP via the PHP_INI_MEMORY_LIMIT environment variable.') |
|
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
|
|
|
224
|
224
|
return trim($value); |
|
@@ -231,9 +231,9 @@ discard block |
|
|
block discarded – undo |
|
231
|
231
|
|
|
232
|
232
|
$uploadMaxFileSize = $aentHelper->question('<info>Maximum file size for uploaded files</info> (keep empty to stay with the default 2M)') |
|
233
|
233
|
->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.') |
|
234
|
|
- ->setValidator(function (string $value) { |
|
|
234
|
+ ->setValidator(function(string $value) { |
|
235
|
235
|
if (trim($value) !== '' && !\preg_match('/^[0-9]+([MGK])?$/i', $value)) { |
|
236
|
|
- throw new \InvalidArgumentException('Invalid value: '.$value); |
|
|
236
|
+ throw new \InvalidArgumentException('Invalid value: ' . $value); |
|
237
|
237
|
} |
|
238
|
238
|
|
|
239
|
239
|
return trim($value); |
|
@@ -256,7 +256,7 @@ discard block |
|
|
block discarded – undo |
|
256
|
256
|
|
|
257
|
257
|
if ($depend !== '') { |
|
258
|
258
|
$service->addDependsOn($depend); |
|
259
|
|
- $this->output->writeln('<info>Added dependency: '.$depend.'</info>'); |
|
|
259
|
+ $this->output->writeln('<info>Added dependency: ' . $depend . '</info>'); |
|
260
|
260
|
} |
|
261
|
261
|
} while ($depend !== ''); |
|
262
|
262
|
$aentHelper->spacer(); |