diff --git a/README.md b/README.md
index 262f271d..e605d8b0 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ Despite how you built the project, you are going to need to install it now, by f
* If you are going to use MySQL or PostgreSQL, create an empty database with the name of your choice.
* Recursively grant write permissions to the `data` directory. Shlink uses it to cache some information.
-* Setup the application by running the `bin/install` script. It will guide you through the installation process.
+* Setup the application by running the `bin/install` script. It is a command line tool that will guide you through the installation process. **Take into account that this tool has to be run directly on the server where you plan to host Shlink. Do not run it before uploading/moving it there.**
* Configure the web server of your choice to serve shlink using your short domain.
For example, assuming your domain is doma.in and shlink is in the `/path/to/shlink` folder, this would be the basic configuration for Nginx and Apache.
diff --git a/bin/install b/bin/install
index 0d8dc72c..13c0a3e8 100755
--- a/bin/install
+++ b/bin/install
@@ -2,29 +2,11 @@
[
- Application::class => InstallApplicationFactory::class,
- Filesystem::class => InvokableFactory::class,
- ],
- 'services' => [
- 'config' => [
- ConfigAbstractFactory::class => [
- DatabaseConfigCustomizer::class => [Filesystem::class]
- ],
- ],
- ],
-]);
+/** @var ServiceLocatorInterface $container */
+$container = include __DIR__ . '/../config/install-container.php';
$container->build(Application::class)->run();
diff --git a/bin/update b/bin/update
index 2a7e4091..8e2e02b5 100755
--- a/bin/update
+++ b/bin/update
@@ -2,29 +2,11 @@
[
- Application::class => InstallApplicationFactory::class,
- Filesystem::class => InvokableFactory::class,
- ],
- 'services' => [
- 'config' => [
- ConfigAbstractFactory::class => [
- DatabaseConfigCustomizer::class => [Filesystem::class]
- ],
- ],
- ],
-]);
+/** @var ServiceLocatorInterface $container */
+$container = include __DIR__ . '/../config/install-container.php';
$container->build(Application::class, ['isUpdate' => true])->run();
diff --git a/composer.json b/composer.json
index 6a2c3b14..6111bd80 100644
--- a/composer.json
+++ b/composer.json
@@ -61,7 +61,8 @@
"Shlinkio\\Shlink\\CLI\\": "module/CLI/src",
"Shlinkio\\Shlink\\Rest\\": "module/Rest/src",
"Shlinkio\\Shlink\\Core\\": "module/Core/src",
- "Shlinkio\\Shlink\\Common\\": "module/Common/src"
+ "Shlinkio\\Shlink\\Common\\": "module/Common/src",
+ "Shlinkio\\Shlink\\Installer\\": "module/Installer/src"
},
"files": [
"module/Common/functions/functions.php"
@@ -78,7 +79,8 @@
"ShlinkioTest\\Shlink\\Common\\": [
"module/Common/test",
"module/Common/test-func"
- ]
+ ],
+ "ShlinkioTest\\Shlink\\Installer\\": "module/Installer/test"
}
},
"scripts": {
@@ -101,8 +103,8 @@
"phpcov merge build --html build/html"
],
"stan": "phpstan analyse module/*/src/ --level=6 -c phpstan.neon",
- "infect": "infection --threads=4 --min-msi=55 --only-covered --log-verbosity=2",
- "infect-show": "infection --threads=4 --min-msi=55 --only-covered --log-verbosity=2 --show-mutations",
+ "infect": "infection --threads=4 --min-msi=60 --only-covered --log-verbosity=2",
+ "infect-show": "infection --threads=4 --min-msi=60 --only-covered --log-verbosity=2 --show-mutations",
"expressive": "expressive"
},
"config": {
diff --git a/config/config.php b/config/config.php
index 506e29db..744d99d0 100644
--- a/config/config.php
+++ b/config/config.php
@@ -1,23 +1,12 @@
getMergedConfig();
diff --git a/config/install-container.php b/config/install-container.php
new file mode 100644
index 00000000..0db90897
--- /dev/null
+++ b/config/install-container.php
@@ -0,0 +1,29 @@
+ [
+ Application::class => InstallApplicationFactory::class,
+ Filesystem::class => InvokableFactory::class,
+ ],
+ 'services' => [
+ 'config' => [
+ ConfigAbstractFactory::class => [
+ DatabaseConfigCustomizer::class => [Filesystem::class],
+ ],
+ ],
+ ],
+]);
+return $container;
diff --git a/module/CLI/config/cli.config.php b/module/CLI/config/cli.config.php
index 501cb668..fb07cb47 100644
--- a/module/CLI/config/cli.config.php
+++ b/module/CLI/config/cli.config.php
@@ -1,13 +1,14 @@
[
- 'locale' => Common\env('CLI_LOCALE', 'en'),
+ 'locale' => env('CLI_LOCALE', 'en'),
'commands' => [
Command\ShortUrl\GenerateShortUrlCommand::NAME => Command\ShortUrl\GenerateShortUrlCommand::class,
Command\ShortUrl\ResolveUrlCommand::NAME => Command\ShortUrl\ResolveUrlCommand::class,
diff --git a/module/CLI/config/dependencies.config.php b/module/CLI/config/dependencies.config.php
index f6f441c6..371c9175 100644
--- a/module/CLI/config/dependencies.config.php
+++ b/module/CLI/config/dependencies.config.php
@@ -1,8 +1,8 @@
[
'factories' => [
- Application::class => ApplicationFactory::class,
+ Application::class => Factory\ApplicationFactory::class,
Command\ShortUrl\GenerateShortUrlCommand::class => ConfigAbstractFactory::class,
Command\ShortUrl\ResolveUrlCommand::class => ConfigAbstractFactory::class,
diff --git a/module/CLI/src/Install/Plugin/ConfigCustomizerInterface.php b/module/CLI/src/Install/Plugin/ConfigCustomizerInterface.php
deleted file mode 100644
index 0a2bf054..00000000
--- a/module/CLI/src/Install/Plugin/ConfigCustomizerInterface.php
+++ /dev/null
@@ -1,17 +0,0 @@
-title('APPLICATION');
diff --git a/module/Installer/src/Config/Plugin/ConfigCustomizerInterface.php b/module/Installer/src/Config/Plugin/ConfigCustomizerInterface.php
new file mode 100644
index 00000000..908f6f90
--- /dev/null
+++ b/module/Installer/src/Config/Plugin/ConfigCustomizerInterface.php
@@ -0,0 +1,12 @@
+ 'pdo_mysql',
'PostgreSQL' => 'pdo_pgsql',
'SQLite' => 'pdo_sqlite',
@@ -27,12 +27,9 @@ class DatabaseConfigCustomizer implements ConfigCustomizerInterface
}
/**
- * @param SymfonyStyle $io
- * @param CustomizableAppConfig $appConfig
- * @return void
* @throws IOException
*/
- public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig)
+ public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
{
$io->title('DATABASE');
diff --git a/module/CLI/src/Install/Plugin/LanguageConfigCustomizer.php b/module/Installer/src/Config/Plugin/LanguageConfigCustomizer.php
similarity index 75%
rename from module/CLI/src/Install/Plugin/LanguageConfigCustomizer.php
rename to module/Installer/src/Config/Plugin/LanguageConfigCustomizer.php
index 15125d32..1a7a2de4 100644
--- a/module/CLI/src/Install/Plugin/LanguageConfigCustomizer.php
+++ b/module/Installer/src/Config/Plugin/LanguageConfigCustomizer.php
@@ -1,21 +1,16 @@
title('LANGUAGE');
diff --git a/module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizer.php b/module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php
similarity index 79%
rename from module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizer.php
rename to module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php
index d010667d..729ec2f8 100644
--- a/module/CLI/src/Install/Plugin/UrlShortenerConfigCustomizer.php
+++ b/module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php
@@ -1,20 +1,16 @@
title('URL SHORTENER');
@@ -36,7 +32,7 @@ class UrlShortenerConfigCustomizer implements ConfigCustomizerInterface
function ($value) {
return $value;
}
- ) ?: \str_shuffle(UrlShortener::DEFAULT_CHARS),
+ ) ?: str_shuffle(UrlShortener::DEFAULT_CHARS),
'VALIDATE_URL' => $io->confirm('Do you want to validate long urls by 200 HTTP status code on response'),
]);
}
diff --git a/module/Installer/src/ConfigProvider.php b/module/Installer/src/ConfigProvider.php
new file mode 100644
index 00000000..6be4cf16
--- /dev/null
+++ b/module/Installer/src/ConfigProvider.php
@@ -0,0 +1,15 @@
+filesystem->exists(
- __DIR__ . '/../../../test-resources/' . InstallCommand::GENERATED_CONFIG_PATH
+ __DIR__ . '/../../test-resources/' . InstallCommand::GENERATED_CONFIG_PATH
)->willReturn(true);
$this->commandTester->setInputs([
'',
'/foo/bar/wrong_previous_shlink',
'',
- __DIR__ . '/../../../test-resources',
+ __DIR__ . '/../../test-resources',
]);
$this->commandTester->execute([]);
diff --git a/module/CLI/test/Install/Plugin/ApplicationConfigCustomizerTest.php b/module/Installer/test/Config/Plugin/ApplicationConfigCustomizerTest.php
similarity index 92%
rename from module/CLI/test/Install/Plugin/ApplicationConfigCustomizerTest.php
rename to module/Installer/test/Config/Plugin/ApplicationConfigCustomizerTest.php
index 5450d0b1..9a5bc3c5 100644
--- a/module/CLI/test/Install/Plugin/ApplicationConfigCustomizerTest.php
+++ b/module/Installer/test/Config/Plugin/ApplicationConfigCustomizerTest.php
@@ -1,13 +1,13 @@
\n"
"Language-Team: \n"
"Language: es_ES\n"
@@ -89,11 +89,22 @@ msgstr ""
"El tipo de autorización proporcionado %s no está soportado. En vez de eso "
"utiliza Bearer."
-#, php-format
+#, fuzzy, php-format
+#| msgid ""
+#| "Missing or invalid auth token provided. Perform a new authentication "
+#| "request and send provided token on every new request on the \"%s\" header"
msgid ""
"Missing or invalid auth token provided. Perform a new authentication request "
-"and send provided token on every new request on the \"%s\" header"
+"and send provided token on every new request on the %s header"
msgstr ""
"No se ha proporcionado token de autenticación o este es inválido. Realiza "
"una nueva petición de autenticación y envía el token proporcionado en cada "
"nueva petición en la cabecera \"%s\""
+
+#, php-format
+msgid ""
+"Expected one of the following authentication headers, but none were "
+"provided, [\"%s\"]"
+msgstr ""
+"Se esperaba una de las siguientes cabeceras de autenticación, pero no se "
+"proporcionó ninguna, [\"%s\"]"
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index af71c7cd..f9f7797b 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -17,6 +17,9 @@
./module/CLI/test
+
+ ./module/Installer/test
+