mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-27 20:11:34 +03:00
Merge pull request #220 from acelaya/feature/installer-module
Feature/installer module
This commit is contained in:
commit
9a2ca35e6e
31 changed files with 155 additions and 158 deletions
|
@ -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.
|
* 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.
|
* 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.
|
* 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.
|
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.
|
||||||
|
|
28
bin/install
28
bin/install
|
@ -2,29 +2,11 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Shlinkio\Shlink\CLI\Factory\InstallApplicationFactory;
|
namespace Shlinkio\Shlink\Installer;
|
||||||
use Shlinkio\Shlink\CLI\Install\Plugin\DatabaseConfigCustomizer;
|
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Zend\ServiceManager\ServiceLocatorInterface;
|
||||||
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
|
|
||||||
use Zend\ServiceManager\Factory\InvokableFactory;
|
|
||||||
use Zend\ServiceManager\ServiceManager;
|
|
||||||
|
|
||||||
chdir(dirname(__DIR__));
|
/** @var ServiceLocatorInterface $container */
|
||||||
|
$container = include __DIR__ . '/../config/install-container.php';
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
|
||||||
|
|
||||||
$container = new ServiceManager([
|
|
||||||
'factories' => [
|
|
||||||
Application::class => InstallApplicationFactory::class,
|
|
||||||
Filesystem::class => InvokableFactory::class,
|
|
||||||
],
|
|
||||||
'services' => [
|
|
||||||
'config' => [
|
|
||||||
ConfigAbstractFactory::class => [
|
|
||||||
DatabaseConfigCustomizer::class => [Filesystem::class]
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
$container->build(Application::class)->run();
|
$container->build(Application::class)->run();
|
||||||
|
|
28
bin/update
28
bin/update
|
@ -2,29 +2,11 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Shlinkio\Shlink\CLI\Factory\InstallApplicationFactory;
|
namespace Shlinkio\Shlink\Installer;
|
||||||
use Shlinkio\Shlink\CLI\Install\Plugin\DatabaseConfigCustomizer;
|
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Zend\ServiceManager\ServiceLocatorInterface;
|
||||||
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
|
|
||||||
use Zend\ServiceManager\Factory\InvokableFactory;
|
|
||||||
use Zend\ServiceManager\ServiceManager;
|
|
||||||
|
|
||||||
chdir(dirname(__DIR__));
|
/** @var ServiceLocatorInterface $container */
|
||||||
|
$container = include __DIR__ . '/../config/install-container.php';
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
|
||||||
|
|
||||||
$container = new ServiceManager([
|
|
||||||
'factories' => [
|
|
||||||
Application::class => InstallApplicationFactory::class,
|
|
||||||
Filesystem::class => InvokableFactory::class,
|
|
||||||
],
|
|
||||||
'services' => [
|
|
||||||
'config' => [
|
|
||||||
ConfigAbstractFactory::class => [
|
|
||||||
DatabaseConfigCustomizer::class => [Filesystem::class]
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
$container->build(Application::class, ['isUpdate' => true])->run();
|
$container->build(Application::class, ['isUpdate' => true])->run();
|
||||||
|
|
|
@ -61,7 +61,8 @@
|
||||||
"Shlinkio\\Shlink\\CLI\\": "module/CLI/src",
|
"Shlinkio\\Shlink\\CLI\\": "module/CLI/src",
|
||||||
"Shlinkio\\Shlink\\Rest\\": "module/Rest/src",
|
"Shlinkio\\Shlink\\Rest\\": "module/Rest/src",
|
||||||
"Shlinkio\\Shlink\\Core\\": "module/Core/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": [
|
"files": [
|
||||||
"module/Common/functions/functions.php"
|
"module/Common/functions/functions.php"
|
||||||
|
@ -78,7 +79,8 @@
|
||||||
"ShlinkioTest\\Shlink\\Common\\": [
|
"ShlinkioTest\\Shlink\\Common\\": [
|
||||||
"module/Common/test",
|
"module/Common/test",
|
||||||
"module/Common/test-func"
|
"module/Common/test-func"
|
||||||
]
|
],
|
||||||
|
"ShlinkioTest\\Shlink\\Installer\\": "module/Installer/test"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -101,8 +103,8 @@
|
||||||
"phpcov merge build --html build/html"
|
"phpcov merge build --html build/html"
|
||||||
],
|
],
|
||||||
"stan": "phpstan analyse module/*/src/ --level=6 -c phpstan.neon",
|
"stan": "phpstan analyse module/*/src/ --level=6 -c phpstan.neon",
|
||||||
"infect": "infection --threads=4 --min-msi=55 --only-covered --log-verbosity=2",
|
"infect": "infection --threads=4 --min-msi=60 --only-covered --log-verbosity=2",
|
||||||
"infect-show": "infection --threads=4 --min-msi=55 --only-covered --log-verbosity=2 --show-mutations",
|
"infect-show": "infection --threads=4 --min-msi=60 --only-covered --log-verbosity=2 --show-mutations",
|
||||||
"expressive": "expressive"
|
"expressive": "expressive"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|
|
@ -1,23 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Shlinkio\Shlink;
|
||||||
|
|
||||||
use Acelaya\ExpressiveErrorHandler;
|
use Acelaya\ExpressiveErrorHandler;
|
||||||
use Shlinkio\Shlink\CLI;
|
|
||||||
use Shlinkio\Shlink\Common;
|
|
||||||
use Shlinkio\Shlink\Core;
|
|
||||||
use Shlinkio\Shlink\Rest;
|
|
||||||
use Zend\ConfigAggregator;
|
use Zend\ConfigAggregator;
|
||||||
use Zend\Expressive;
|
use Zend\Expressive;
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration files are loaded in a specific order. First ``global.php``, then ``*.global.php``.
|
|
||||||
* then ``local.php`` and finally ``*.local.php``. This way local settings overwrite global settings.
|
|
||||||
*
|
|
||||||
* The configuration can be cached. This can be done by setting ``config_cache_enabled`` to ``true``.
|
|
||||||
*
|
|
||||||
* Obviously, if you use closures in your config you can't cache it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
return (new ConfigAggregator\ConfigAggregator([
|
return (new ConfigAggregator\ConfigAggregator([
|
||||||
Expressive\ConfigProvider::class,
|
Expressive\ConfigProvider::class,
|
||||||
Expressive\Router\ConfigProvider::class,
|
Expressive\Router\ConfigProvider::class,
|
||||||
|
@ -31,6 +20,7 @@ return (new ConfigAggregator\ConfigAggregator([
|
||||||
Common\ConfigProvider::class,
|
Common\ConfigProvider::class,
|
||||||
Core\ConfigProvider::class,
|
Core\ConfigProvider::class,
|
||||||
CLI\ConfigProvider::class,
|
CLI\ConfigProvider::class,
|
||||||
|
Installer\ConfigProvider::class,
|
||||||
Rest\ConfigProvider::class,
|
Rest\ConfigProvider::class,
|
||||||
new ConfigAggregator\ZendConfigProvider('config/{autoload/{{,*.}global,{,*.}local},params/generated_config}.php'),
|
new ConfigAggregator\ZendConfigProvider('config/{autoload/{{,*.}global,{,*.}local},params/generated_config}.php'),
|
||||||
], 'data/cache/app_config.php'))->getMergedConfig();
|
], 'data/cache/app_config.php'))->getMergedConfig();
|
||||||
|
|
29
config/install-container.php
Normal file
29
config/install-container.php
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Shlinkio\Shlink\Installer\Config\Plugin\DatabaseConfigCustomizer;
|
||||||
|
use Shlinkio\Shlink\Installer\Factory\InstallApplicationFactory;
|
||||||
|
use Symfony\Component\Console\Application;
|
||||||
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
|
||||||
|
use Zend\ServiceManager\Factory\InvokableFactory;
|
||||||
|
use Zend\ServiceManager\ServiceManager;
|
||||||
|
|
||||||
|
chdir(dirname(__DIR__));
|
||||||
|
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
$container = new ServiceManager([
|
||||||
|
'factories' => [
|
||||||
|
Application::class => InstallApplicationFactory::class,
|
||||||
|
Filesystem::class => InvokableFactory::class,
|
||||||
|
],
|
||||||
|
'services' => [
|
||||||
|
'config' => [
|
||||||
|
ConfigAbstractFactory::class => [
|
||||||
|
DatabaseConfigCustomizer::class => [Filesystem::class],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
return $container;
|
|
@ -1,13 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Shlinkio\Shlink\CLI\Command;
|
namespace Shlinkio\Shlink\CLI;
|
||||||
use Shlinkio\Shlink\Common;
|
|
||||||
|
use function Shlinkio\Shlink\Common\env;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
'cli' => [
|
'cli' => [
|
||||||
'locale' => Common\env('CLI_LOCALE', 'en'),
|
'locale' => env('CLI_LOCALE', 'en'),
|
||||||
'commands' => [
|
'commands' => [
|
||||||
Command\ShortUrl\GenerateShortUrlCommand::NAME => Command\ShortUrl\GenerateShortUrlCommand::class,
|
Command\ShortUrl\GenerateShortUrlCommand::NAME => Command\ShortUrl\GenerateShortUrlCommand::class,
|
||||||
Command\ShortUrl\ResolveUrlCommand::NAME => Command\ShortUrl\ResolveUrlCommand::class,
|
Command\ShortUrl\ResolveUrlCommand::NAME => Command\ShortUrl\ResolveUrlCommand::class,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Shlinkio\Shlink\CLI\Command;
|
namespace Shlinkio\Shlink\CLI;
|
||||||
use Shlinkio\Shlink\CLI\Factory\ApplicationFactory;
|
|
||||||
use Shlinkio\Shlink\Common\Service\IpApiLocationResolver;
|
use Shlinkio\Shlink\Common\Service\IpApiLocationResolver;
|
||||||
use Shlinkio\Shlink\Common\Service\PreviewGenerator;
|
use Shlinkio\Shlink\Common\Service\PreviewGenerator;
|
||||||
use Shlinkio\Shlink\Core\Service;
|
use Shlinkio\Shlink\Core\Service;
|
||||||
|
@ -15,7 +15,7 @@ return [
|
||||||
|
|
||||||
'dependencies' => [
|
'dependencies' => [
|
||||||
'factories' => [
|
'factories' => [
|
||||||
Application::class => ApplicationFactory::class,
|
Application::class => Factory\ApplicationFactory::class,
|
||||||
|
|
||||||
Command\ShortUrl\GenerateShortUrlCommand::class => ConfigAbstractFactory::class,
|
Command\ShortUrl\GenerateShortUrlCommand::class => ConfigAbstractFactory::class,
|
||||||
Command\ShortUrl\ResolveUrlCommand::class => ConfigAbstractFactory::class,
|
Command\ShortUrl\ResolveUrlCommand::class => ConfigAbstractFactory::class,
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\CLI\Install\Plugin;
|
|
||||||
|
|
||||||
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
|
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
||||||
|
|
||||||
interface ConfigCustomizerInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param SymfonyStyle $io
|
|
||||||
* @param CustomizableAppConfig $appConfig
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig);
|
|
||||||
}
|
|
4
module/Installer/config/module.config.php
Normal file
4
module/Installer/config/module.config.php
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
return [];
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\CLI\Command\Install;
|
namespace Shlinkio\Shlink\Installer\Command;
|
||||||
|
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Shlinkio\Shlink\CLI\Install\ConfigCustomizerManagerInterface;
|
use Shlinkio\Shlink\Installer\Config\ConfigCustomizerManagerInterface;
|
||||||
use Shlinkio\Shlink\CLI\Install\Plugin;
|
use Shlinkio\Shlink\Installer\Config\Plugin;
|
||||||
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
|
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Console\Exception\LogicException;
|
use Symfony\Component\Console\Exception\LogicException;
|
||||||
|
@ -23,7 +23,7 @@ use Zend\Config\Writer\WriterInterface;
|
||||||
|
|
||||||
class InstallCommand extends Command
|
class InstallCommand extends Command
|
||||||
{
|
{
|
||||||
const GENERATED_CONFIG_PATH = 'config/params/generated_config.php';
|
public const GENERATED_CONFIG_PATH = 'config/params/generated_config.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SymfonyStyle
|
* @var SymfonyStyle
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\CLI\Install;
|
namespace Shlinkio\Shlink\Installer\Config;
|
||||||
|
|
||||||
use Shlinkio\Shlink\CLI\Install\Plugin\ConfigCustomizerInterface;
|
use Shlinkio\Shlink\Installer\Config\Plugin\ConfigCustomizerInterface;
|
||||||
use Zend\ServiceManager\AbstractPluginManager;
|
use Zend\ServiceManager\AbstractPluginManager;
|
||||||
|
|
||||||
class ConfigCustomizerManager extends AbstractPluginManager implements ConfigCustomizerManagerInterface
|
class ConfigCustomizerManager extends AbstractPluginManager implements ConfigCustomizerManagerInterface
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\CLI\Install;
|
namespace Shlinkio\Shlink\Installer\Config;
|
||||||
|
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
|
@ -1,22 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\CLI\Install\Plugin;
|
namespace Shlinkio\Shlink\Installer\Config\Plugin;
|
||||||
|
|
||||||
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
|
|
||||||
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
|
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
|
||||||
|
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class ApplicationConfigCustomizer implements ConfigCustomizerInterface
|
class ApplicationConfigCustomizer implements ConfigCustomizerInterface
|
||||||
{
|
{
|
||||||
use StringUtilsTrait;
|
use StringUtilsTrait;
|
||||||
|
|
||||||
/**
|
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
|
||||||
* @param SymfonyStyle $io
|
|
||||||
* @param CustomizableAppConfig $appConfig
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig)
|
|
||||||
{
|
{
|
||||||
$io->title('APPLICATION');
|
$io->title('APPLICATION');
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Shlinkio\Shlink\Installer\Config\Plugin;
|
||||||
|
|
||||||
|
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
|
interface ConfigCustomizerInterface
|
||||||
|
{
|
||||||
|
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void;
|
||||||
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\CLI\Install\Plugin;
|
namespace Shlinkio\Shlink\Installer\Config\Plugin;
|
||||||
|
|
||||||
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
|
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\Filesystem\Exception\IOException;
|
use Symfony\Component\Filesystem\Exception\IOException;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
|
||||||
class DatabaseConfigCustomizer implements ConfigCustomizerInterface
|
class DatabaseConfigCustomizer implements ConfigCustomizerInterface
|
||||||
{
|
{
|
||||||
const DATABASE_DRIVERS = [
|
private const DATABASE_DRIVERS = [
|
||||||
'MySQL' => 'pdo_mysql',
|
'MySQL' => 'pdo_mysql',
|
||||||
'PostgreSQL' => 'pdo_pgsql',
|
'PostgreSQL' => 'pdo_pgsql',
|
||||||
'SQLite' => 'pdo_sqlite',
|
'SQLite' => 'pdo_sqlite',
|
||||||
|
@ -27,12 +27,9 @@ class DatabaseConfigCustomizer implements ConfigCustomizerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SymfonyStyle $io
|
|
||||||
* @param CustomizableAppConfig $appConfig
|
|
||||||
* @return void
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig)
|
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
|
||||||
{
|
{
|
||||||
$io->title('DATABASE');
|
$io->title('DATABASE');
|
||||||
|
|
|
@ -1,21 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\CLI\Install\Plugin;
|
namespace Shlinkio\Shlink\Installer\Config\Plugin;
|
||||||
|
|
||||||
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
|
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class LanguageConfigCustomizer implements ConfigCustomizerInterface
|
class LanguageConfigCustomizer implements ConfigCustomizerInterface
|
||||||
{
|
{
|
||||||
const SUPPORTED_LANGUAGES = ['en', 'es'];
|
private const SUPPORTED_LANGUAGES = ['en', 'es'];
|
||||||
|
|
||||||
/**
|
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
|
||||||
* @param SymfonyStyle $io
|
|
||||||
* @param CustomizableAppConfig $appConfig
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig)
|
|
||||||
{
|
{
|
||||||
$io->title('LANGUAGE');
|
$io->title('LANGUAGE');
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\CLI\Install\Plugin;
|
namespace Shlinkio\Shlink\Installer\Config\Plugin;
|
||||||
|
|
||||||
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
|
|
||||||
use Shlinkio\Shlink\Core\Service\UrlShortener;
|
use Shlinkio\Shlink\Core\Service\UrlShortener;
|
||||||
|
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
use function str_shuffle;
|
||||||
|
|
||||||
class UrlShortenerConfigCustomizer implements ConfigCustomizerInterface
|
class UrlShortenerConfigCustomizer implements ConfigCustomizerInterface
|
||||||
{
|
{
|
||||||
/**
|
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void
|
||||||
* @param SymfonyStyle $io
|
|
||||||
* @param CustomizableAppConfig $appConfig
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig)
|
|
||||||
{
|
{
|
||||||
$io->title('URL SHORTENER');
|
$io->title('URL SHORTENER');
|
||||||
|
|
||||||
|
@ -36,7 +32,7 @@ class UrlShortenerConfigCustomizer implements ConfigCustomizerInterface
|
||||||
function ($value) {
|
function ($value) {
|
||||||
return $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'),
|
'VALIDATE_URL' => $io->confirm('Do you want to validate long urls by 200 HTTP status code on response'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
15
module/Installer/src/ConfigProvider.php
Normal file
15
module/Installer/src/ConfigProvider.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Shlinkio\Shlink\Installer;
|
||||||
|
|
||||||
|
use Zend\Config\Factory;
|
||||||
|
use Zend\Stdlib\Glob;
|
||||||
|
|
||||||
|
class ConfigProvider
|
||||||
|
{
|
||||||
|
public function __invoke()
|
||||||
|
{
|
||||||
|
return Factory::fromFiles(Glob::glob(__DIR__ . '/../config/{,*.}config.php', Glob::GLOB_BRACE));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\CLI\Factory;
|
namespace Shlinkio\Shlink\Installer\Factory;
|
||||||
|
|
||||||
use Interop\Container\ContainerInterface;
|
use Interop\Container\ContainerInterface;
|
||||||
use Interop\Container\Exception\ContainerException;
|
use Interop\Container\Exception\ContainerException;
|
||||||
use Shlinkio\Shlink\CLI\Command\Install\InstallCommand;
|
use Shlinkio\Shlink\Installer\Command\InstallCommand;
|
||||||
use Shlinkio\Shlink\CLI\Install\ConfigCustomizerManager;
|
use Shlinkio\Shlink\Installer\Config\ConfigCustomizerManager;
|
||||||
use Shlinkio\Shlink\CLI\Install\Plugin;
|
use Shlinkio\Shlink\Installer\Config\Plugin;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Console\Exception\LogicException;
|
use Symfony\Component\Console\Exception\LogicException;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\CLI\Model;
|
namespace Shlinkio\Shlink\Installer\Model;
|
||||||
|
|
||||||
use Zend\Stdlib\ArraySerializableInterface;
|
use Zend\Stdlib\ArraySerializableInterface;
|
||||||
|
|
||||||
final class CustomizableAppConfig implements ArraySerializableInterface
|
final class CustomizableAppConfig implements ArraySerializableInterface
|
||||||
{
|
{
|
||||||
const SQLITE_DB_PATH = 'data/database.sqlite';
|
public const SQLITE_DB_PATH = 'data/database.sqlite';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
|
@ -1,15 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ShlinkioTest\Shlink\CLI\Command\Install;
|
namespace ShlinkioTest\Shlink\Installer\Command;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Prophecy\Argument;
|
use Prophecy\Argument;
|
||||||
use Prophecy\Prophecy\MethodProphecy;
|
use Prophecy\Prophecy\MethodProphecy;
|
||||||
use Prophecy\Prophecy\ObjectProphecy;
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
use Shlinkio\Shlink\CLI\Command\Install\InstallCommand;
|
use Shlinkio\Shlink\Installer\Command\InstallCommand;
|
||||||
use Shlinkio\Shlink\CLI\Install\ConfigCustomizerManagerInterface;
|
use Shlinkio\Shlink\Installer\Config\ConfigCustomizerManagerInterface;
|
||||||
use Shlinkio\Shlink\CLI\Install\Plugin\ConfigCustomizerInterface;
|
use Shlinkio\Shlink\Installer\Config\Plugin\ConfigCustomizerInterface;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Console\Helper\ProcessHelper;
|
use Symfony\Component\Console\Helper\ProcessHelper;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
@ -131,14 +131,14 @@ class InstallCommandTest extends TestCase
|
||||||
|
|
||||||
/** @var MethodProphecy $importedConfigExists */
|
/** @var MethodProphecy $importedConfigExists */
|
||||||
$importedConfigExists = $this->filesystem->exists(
|
$importedConfigExists = $this->filesystem->exists(
|
||||||
__DIR__ . '/../../../test-resources/' . InstallCommand::GENERATED_CONFIG_PATH
|
__DIR__ . '/../../test-resources/' . InstallCommand::GENERATED_CONFIG_PATH
|
||||||
)->willReturn(true);
|
)->willReturn(true);
|
||||||
|
|
||||||
$this->commandTester->setInputs([
|
$this->commandTester->setInputs([
|
||||||
'',
|
'',
|
||||||
'/foo/bar/wrong_previous_shlink',
|
'/foo/bar/wrong_previous_shlink',
|
||||||
'',
|
'',
|
||||||
__DIR__ . '/../../../test-resources',
|
__DIR__ . '/../../test-resources',
|
||||||
]);
|
]);
|
||||||
$this->commandTester->execute([]);
|
$this->commandTester->execute([]);
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
|
namespace ShlinkioTest\Shlink\Installer\Config\Plugin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Prophecy\Argument;
|
use Prophecy\Argument;
|
||||||
use Prophecy\Prophecy\ObjectProphecy;
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
use Shlinkio\Shlink\CLI\Install\Plugin\ApplicationConfigCustomizer;
|
use Shlinkio\Shlink\Installer\Config\Plugin\ApplicationConfigCustomizer;
|
||||||
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
|
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class ApplicationConfigCustomizerTest extends TestCase
|
class ApplicationConfigCustomizerTest extends TestCase
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
|
namespace ShlinkioTest\Shlink\Installer\Config\Plugin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Prophecy\Argument;
|
use Prophecy\Argument;
|
||||||
use Prophecy\Prophecy\ObjectProphecy;
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
use Shlinkio\Shlink\CLI\Install\Plugin\DatabaseConfigCustomizer;
|
use Shlinkio\Shlink\Installer\Config\Plugin\DatabaseConfigCustomizer;
|
||||||
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
|
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
|
namespace ShlinkioTest\Shlink\Installer\Config\Plugin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Prophecy\Argument;
|
use Prophecy\Argument;
|
||||||
use Prophecy\Prophecy\ObjectProphecy;
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
use Shlinkio\Shlink\CLI\Install\Plugin\LanguageConfigCustomizer;
|
use Shlinkio\Shlink\Installer\Config\Plugin\LanguageConfigCustomizer;
|
||||||
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
|
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class LanguageConfigCustomizerTest extends TestCase
|
class LanguageConfigCustomizerTest extends TestCase
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
|
namespace ShlinkioTest\Shlink\Installer\Config\Plugin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Prophecy\Argument;
|
use Prophecy\Argument;
|
||||||
use Prophecy\Prophecy\ObjectProphecy;
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
use Shlinkio\Shlink\CLI\Install\Plugin\UrlShortenerConfigCustomizer;
|
use Shlinkio\Shlink\Installer\Config\Plugin\UrlShortenerConfigCustomizer;
|
||||||
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
|
use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class UrlShortenerConfigCustomizerTest extends TestCase
|
class UrlShortenerConfigCustomizerTest extends TestCase
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ShlinkioTest\Shlink\CLI\Factory;
|
namespace ShlinkioTest\Shlink\Installer\Factory;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Shlinkio\Shlink\CLI\Factory\InstallApplicationFactory;
|
use Shlinkio\Shlink\Installer\Factory\InstallApplicationFactory;
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Zend\ServiceManager\ServiceManager;
|
use Zend\ServiceManager\ServiceManager;
|
Binary file not shown.
|
@ -1,8 +1,8 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Shlink 1.0\n"
|
"Project-Id-Version: Shlink 1.0\n"
|
||||||
"POT-Creation-Date: 2018-09-15 18:02+0200\n"
|
"POT-Creation-Date: 2018-09-29 10:08+0200\n"
|
||||||
"PO-Revision-Date: 2018-09-15 18:03+0200\n"
|
"PO-Revision-Date: 2018-09-29 10:08+0200\n"
|
||||||
"Last-Translator: Alejandro Celaya <alejandro@alejandrocelaya.com>\n"
|
"Last-Translator: Alejandro Celaya <alejandro@alejandrocelaya.com>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: es_ES\n"
|
"Language: es_ES\n"
|
||||||
|
@ -89,11 +89,22 @@ msgstr ""
|
||||||
"El tipo de autorización proporcionado %s no está soportado. En vez de eso "
|
"El tipo de autorización proporcionado %s no está soportado. En vez de eso "
|
||||||
"utiliza Bearer."
|
"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 ""
|
msgid ""
|
||||||
"Missing or invalid auth token provided. Perform a new authentication request "
|
"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 ""
|
msgstr ""
|
||||||
"No se ha proporcionado token de autenticación o este es inválido. Realiza "
|
"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 "
|
"una nueva petición de autenticación y envía el token proporcionado en cada "
|
||||||
"nueva petición en la cabecera \"%s\""
|
"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\"]"
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
<testsuite name="CLI">
|
<testsuite name="CLI">
|
||||||
<directory>./module/CLI/test</directory>
|
<directory>./module/CLI/test</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
<testsuite name="Installer">
|
||||||
|
<directory>./module/Installer/test</directory>
|
||||||
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
|
|
Loading…
Add table
Reference in a new issue