Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Redis ENV variables #65

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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://[email protected]/123
API_DOCS_ENABLED=1
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
$finder = Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/public')
->in(__DIR__ . '/config/php')
->in(__DIR__ . '/tests');

return (new Config())
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/packages/kdyby.redis.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ extensions:

kdyby.redis:
session:
database: 0
native: no
journal: yes

services:
redis:
Expand Down
2 changes: 1 addition & 1 deletion config/php/contributte.recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] : [];
6 changes: 3 additions & 3 deletions config/php/http.cookie_secure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
13 changes: 9 additions & 4 deletions config/php/kdyby.redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] : [];
14 changes: 7 additions & 7 deletions config/php/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];
Loading