diff --git a/.env.dist b/.env.dist index 9f110d45..e46a6fc3 100644 --- a/.env.dist +++ b/.env.dist @@ -26,6 +26,8 @@ # REDIS_HOST=server # REDIS_PORT=port # REDIS_AUTH="" # optional +# REDIS_DB_CACHE=0 # optional +# REDIS_DB_SESSIONS=1 # optional # SMTP_ENABLED=1 # SMTP_HOST=hostname @@ -61,6 +63,8 @@ DB_PASSWORD=root REDIS_HOST=redis REDIS_PORT=6379 REDIS_AUTH=redis_pass +REDIS_DB_CACHE=0 +REDIS_DB_SESSIONS=1 SENTRY_DSN=https://hash@sentry.io/123 API_DOCS_ENABLED=1 diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index e819323c..0a6a803d 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -9,6 +9,7 @@ $finder = Finder::create() ->in(__DIR__ . '/src') ->in(__DIR__ . '/public') + ->in(__DIR__ . '/config/php') ->in(__DIR__ . '/tests'); return (new Config()) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b5c3b65..15ef876a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added optional ENV variables `REDIS_DB_CACHE` (default `0`) and `REDIS_DB_SESSIONS` (default `1`). + ## 0.12.0 - 2023-02-27 ### Added diff --git a/config/packages/kdyby.redis.neon b/config/packages/kdyby.redis.neon index 54241d88..b2fd7406 100644 --- a/config/packages/kdyby.redis.neon +++ b/config/packages/kdyby.redis.neon @@ -3,8 +3,8 @@ extensions: kdyby.redis: session: - database: 0 native: no + journal: yes services: redis: diff --git a/config/php/contributte.recaptcha.php b/config/php/contributte.recaptcha.php index 9ed0410c..6d2660e7 100644 --- a/config/php/contributte.recaptcha.php +++ b/config/php/contributte.recaptcha.php @@ -5,6 +5,6 @@ $recaptchaConfig = array_filter([ 'siteKey' => env('GOOGLE_RECAPTCHA_SITE_KEY', ''), 'secretKey' => env('GOOGLE_RECAPTCHA_SECRET_KEY', ''), -], static fn ($value): bool => $value !== NULL); +], static fn ($value): bool => $value !== null); return 0 < count($recaptchaConfig) ? ['contributte.recaptcha' => $recaptchaConfig] : []; diff --git a/config/php/http.cookie_secure.php b/config/php/http.cookie_secure.php index ecb0f80d..ba63dd0d 100644 --- a/config/php/http.cookie_secure.php +++ b/config/php/http.cookie_secure.php @@ -2,10 +2,10 @@ declare(strict_types=1); -$secure = $_ENV['COOKIE_SECURE'] ?? NULL; +$secure = $_ENV['COOKIE_SECURE'] ?? null; -if (NULL !== $secure) { - if (in_array($secure, ['1', '0'], FALSE)) { +if (null !== $secure) { + if (in_array($secure, ['1', '0'], false)) { $secure = (bool) $secure; } diff --git a/config/php/kdyby.redis.php b/config/php/kdyby.redis.php index 57057407..d078a9e2 100644 --- a/config/php/kdyby.redis.php +++ b/config/php/kdyby.redis.php @@ -3,9 +3,14 @@ declare(strict_types=1); $redisConfig = array_filter([ - 'host' => env('REDIS_HOST', NULL), - 'port' => env('REDIS_PORT|int', NULL), - 'auth' => env('REDIS_AUTH', NULL), -], static fn ($value): bool => $value !== NULL); + 'host' => env('REDIS_HOST', null), + 'port' => env('REDIS_PORT|int', null), + 'auth' => env('REDIS_AUTH|nullable', null), +], static fn ($value): bool => $value !== null); + +$redisConfig['database'] = env('REDIS_DB_CACHE|int', 0); +$redisConfig['session'] = [ + 'database' => env('REDIS_DB_SESSIONS|int', 1), +]; return 0 < count($redisConfig) ? ['kdyby.redis' => $redisConfig] : []; diff --git a/config/php/mail.php b/config/php/mail.php index 942cedfe..f7be752d 100644 --- a/config/php/mail.php +++ b/config/php/mail.php @@ -3,15 +3,15 @@ declare(strict_types=1); $mailConfig = array_filter([ - 'host' => env('SMTP_HOST', NULL), - 'port' => env('SMTP_PORT|int', NULL), - 'username' => env('SMTP_USERNAME', NULL), - 'password' => env('SMTP_PASSWORD', NULL), - 'secure' => env('SMTP_SECURE', NULL), -], static fn ($value): bool => $value !== NULL); + 'host' => env('SMTP_HOST', null), + 'port' => env('SMTP_PORT|int', null), + 'username' => env('SMTP_USERNAME', null), + 'password' => env('SMTP_PASSWORD', null), + 'secure' => env('SMTP_SECURE', null), +], static fn ($value): bool => $value !== null); return [ 'mail' => array_merge([ - 'smtp' => env('SMTP_ENABLED|bool', FALSE), + 'smtp' => env('SMTP_ENABLED|bool', false), ], $mailConfig), ];