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