mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Updated to latest installer with support for env vars
This commit is contained in:
@@ -51,7 +51,7 @@
|
|||||||
"shlinkio/shlink-config": "^1.5",
|
"shlinkio/shlink-config": "^1.5",
|
||||||
"shlinkio/shlink-event-dispatcher": "^2.3",
|
"shlinkio/shlink-event-dispatcher": "^2.3",
|
||||||
"shlinkio/shlink-importer": "^2.5",
|
"shlinkio/shlink-importer": "^2.5",
|
||||||
"shlinkio/shlink-installer": "dev-develop#a008036 as 7.0",
|
"shlinkio/shlink-installer": "dev-develop#ba32503 as 7.0",
|
||||||
"shlinkio/shlink-ip-geolocation": "^2.2",
|
"shlinkio/shlink-ip-geolocation": "^2.2",
|
||||||
"symfony/console": "^6.0",
|
"symfony/console": "^6.0",
|
||||||
"symfony/filesystem": "^6.0",
|
"symfony/filesystem": "^6.0",
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ return (static function (): array {
|
|||||||
'dbname' => env('DB_NAME', 'shlink'),
|
'dbname' => env('DB_NAME', 'shlink'),
|
||||||
'user' => env('DB_USER'),
|
'user' => env('DB_USER'),
|
||||||
'password' => env('DB_PASSWORD'),
|
'password' => env('DB_PASSWORD'),
|
||||||
'host' => env('DB_HOST', $driver === 'postgres' ? env('DB_UNIX_SOCKET') : null),
|
'host' => env('DB_HOST', env('DB_UNIX_SOCKET')),
|
||||||
'port' => env('DB_PORT', $resolveDefaultPort()),
|
'port' => env('DB_PORT', $resolveDefaultPort()),
|
||||||
'unix_socket' => $isMysqlCompatible ? env('DB_UNIX_SOCKET') : null,
|
'unix_socket' => $isMysqlCompatible ? env('DB_UNIX_SOCKET') : null,
|
||||||
'charset' => $resolveCharset(),
|
'charset' => $resolveCharset(),
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ return [
|
|||||||
Option\Database\DatabaseUserConfigOption::class,
|
Option\Database\DatabaseUserConfigOption::class,
|
||||||
Option\Database\DatabasePasswordConfigOption::class,
|
Option\Database\DatabasePasswordConfigOption::class,
|
||||||
Option\Database\DatabaseUnixSocketConfigOption::class,
|
Option\Database\DatabaseUnixSocketConfigOption::class,
|
||||||
Option\Database\DatabaseSqlitePathConfigOption::class,
|
|
||||||
Option\Database\DatabaseMySqlOptionsConfigOption::class,
|
|
||||||
Option\UrlShortener\ShortDomainHostConfigOption::class,
|
Option\UrlShortener\ShortDomainHostConfigOption::class,
|
||||||
Option\UrlShortener\ShortDomainSchemaConfigOption::class,
|
Option\UrlShortener\ShortDomainSchemaConfigOption::class,
|
||||||
Option\Visit\VisitsWebhooksConfigOption::class,
|
Option\Visit\VisitsWebhooksConfigOption::class,
|
||||||
@@ -27,12 +25,12 @@ return [
|
|||||||
Option\Redirect\BaseUrlRedirectConfigOption::class,
|
Option\Redirect\BaseUrlRedirectConfigOption::class,
|
||||||
Option\Redirect\InvalidShortUrlRedirectConfigOption::class,
|
Option\Redirect\InvalidShortUrlRedirectConfigOption::class,
|
||||||
Option\Redirect\Regular404RedirectConfigOption::class,
|
Option\Redirect\Regular404RedirectConfigOption::class,
|
||||||
Option\Visit\CheckVisitsThresholdConfigOption::class,
|
|
||||||
Option\Visit\VisitsThresholdConfigOption::class,
|
Option\Visit\VisitsThresholdConfigOption::class,
|
||||||
Option\BasePathConfigOption::class,
|
Option\BasePathConfigOption::class,
|
||||||
Option\Worker\TaskWorkerNumConfigOption::class,
|
Option\Worker\TaskWorkerNumConfigOption::class,
|
||||||
Option\Worker\WebWorkerNumConfigOption::class,
|
Option\Worker\WebWorkerNumConfigOption::class,
|
||||||
Option\RedisConfigOption::class,
|
Option\Redis\RedisServersConfigOption::class,
|
||||||
|
Option\Redis\RedisSentinelServiceConfigOption::class,
|
||||||
Option\UrlShortener\ShortCodeLengthOption::class,
|
Option\UrlShortener\ShortCodeLengthOption::class,
|
||||||
Option\Mercure\EnableMercureConfigOption::class,
|
Option\Mercure\EnableMercureConfigOption::class,
|
||||||
Option\Mercure\MercurePublicUrlConfigOption::class,
|
Option\Mercure\MercurePublicUrlConfigOption::class,
|
||||||
|
|||||||
@@ -12,12 +12,25 @@ use Mezzio\Swoole;
|
|||||||
|
|
||||||
use function class_exists;
|
use function class_exists;
|
||||||
use function Shlinkio\Shlink\Config\env;
|
use function Shlinkio\Shlink\Config\env;
|
||||||
|
use function Shlinkio\Shlink\Core\putNotYetDefinedEnv;
|
||||||
|
|
||||||
use const PHP_SAPI;
|
use const PHP_SAPI;
|
||||||
|
|
||||||
$isCli = PHP_SAPI === 'cli';
|
$isCli = PHP_SAPI === 'cli';
|
||||||
|
$isTestEnv = env('APP_ENV') === 'test';
|
||||||
|
|
||||||
return (new ConfigAggregator\ConfigAggregator([
|
return (new ConfigAggregator\ConfigAggregator([
|
||||||
|
! $isTestEnv
|
||||||
|
? new ConfigAggregator\ArrayProvider((new ConfigAggregator\ConfigAggregator([
|
||||||
|
new ConfigAggregator\PhpFileProvider('config/params/generated_config.php'),
|
||||||
|
], null, [function (array $generatedConfig) {
|
||||||
|
foreach ($generatedConfig as $envVar => $value) {
|
||||||
|
putNotYetDefinedEnv($envVar, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}]))->getMergedConfig())
|
||||||
|
: new ConfigAggregator\ArrayProvider([]),
|
||||||
Mezzio\ConfigProvider::class,
|
Mezzio\ConfigProvider::class,
|
||||||
Mezzio\Router\ConfigProvider::class,
|
Mezzio\Router\ConfigProvider::class,
|
||||||
Mezzio\Router\FastRouteRouter\ConfigProvider::class,
|
Mezzio\Router\FastRouteRouter\ConfigProvider::class,
|
||||||
@@ -35,9 +48,9 @@ return (new ConfigAggregator\ConfigAggregator([
|
|||||||
CLI\ConfigProvider::class,
|
CLI\ConfigProvider::class,
|
||||||
Rest\ConfigProvider::class,
|
Rest\ConfigProvider::class,
|
||||||
new ConfigAggregator\PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
|
new ConfigAggregator\PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
|
||||||
env('APP_ENV') === 'test'
|
$isTestEnv
|
||||||
? new ConfigAggregator\PhpFileProvider('config/test/*.global.php')
|
? new ConfigAggregator\PhpFileProvider('config/test/*.global.php')
|
||||||
: new ConfigAggregator\PhpFileProvider('config/params/generated_config.php'),
|
: new ConfigAggregator\ArrayProvider([]),
|
||||||
], 'data/cache/app_config.php', [
|
], 'data/cache/app_config.php', [
|
||||||
Core\Config\BasePathPrefixer::class,
|
Core\Config\BasePathPrefixer::class,
|
||||||
]))->getMergedConfig();
|
]))->getMergedConfig();
|
||||||
|
|||||||
@@ -13,9 +13,13 @@ use PUGX\Shortid\Factory as ShortIdFactory;
|
|||||||
use Shlinkio\Shlink\Common\Util\DateRange;
|
use Shlinkio\Shlink\Common\Util\DateRange;
|
||||||
|
|
||||||
use function Functional\reduce_left;
|
use function Functional\reduce_left;
|
||||||
|
use function implode;
|
||||||
use function is_array;
|
use function is_array;
|
||||||
|
use function is_scalar;
|
||||||
use function print_r;
|
use function print_r;
|
||||||
|
use function putenv;
|
||||||
use function Shlinkio\Shlink\Common\buildDateRange;
|
use function Shlinkio\Shlink\Common\buildDateRange;
|
||||||
|
use function Shlinkio\Shlink\Config\env;
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
use function str_repeat;
|
use function str_repeat;
|
||||||
|
|
||||||
@@ -116,3 +120,18 @@ function fieldWithUtf8Charset(FieldBuilder $field, array $emConfig, string $coll
|
|||||||
default => $field,
|
default => $field,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function putNotYetDefinedEnv(string $key, mixed $value): void
|
||||||
|
{
|
||||||
|
$isArray = is_array($value);
|
||||||
|
if (!($isArray || is_scalar($value)) || env($key) !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$normalizedValue = $isArray ? implode(',', $value) : match ($value) {
|
||||||
|
true => 'true',
|
||||||
|
false => 'false',
|
||||||
|
default => $value,
|
||||||
|
};
|
||||||
|
putenv(sprintf('%s=%s', $key, $normalizedValue));
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ use Laminas\Stdlib\AbstractOptions;
|
|||||||
|
|
||||||
use function array_key_exists;
|
use function array_key_exists;
|
||||||
use function explode;
|
use function explode;
|
||||||
|
use function Functional\map;
|
||||||
use function is_array;
|
use function is_array;
|
||||||
|
use function trim;
|
||||||
|
|
||||||
class TrackingOptions extends AbstractOptions
|
class TrackingOptions extends AbstractOptions
|
||||||
{
|
{
|
||||||
@@ -108,10 +110,10 @@ class TrackingOptions extends AbstractOptions
|
|||||||
|
|
||||||
protected function setDisableTrackingFrom(string|array|null $disableTrackingFrom): void
|
protected function setDisableTrackingFrom(string|array|null $disableTrackingFrom): void
|
||||||
{
|
{
|
||||||
if (is_array($disableTrackingFrom)) {
|
$this->disableTrackingFrom = match (true) {
|
||||||
$this->disableTrackingFrom = $disableTrackingFrom;
|
is_array($disableTrackingFrom) => $disableTrackingFrom,
|
||||||
} else {
|
$disableTrackingFrom === null => [],
|
||||||
$this->disableTrackingFrom = $disableTrackingFrom === null ? [] : explode(',', $disableTrackingFrom);
|
default => map(explode(',', $disableTrackingFrom), static fn (string $value) => trim($value)),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user