Skip to content
Draft
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
120 changes: 120 additions & 0 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,124 @@

],

/*
|--------------------------------------------------------------------------
| Valkey Databases
|--------------------------------------------------------------------------
|
| Valkey is a BSD-licensed, high performance key-value store that is fully
| wire-compatible with Redis. Each option falls back to its "REDIS_*"
| equivalent, so existing Redis applications may adopt Valkey without any
| additional configuration by setting the "VALKEY_FROM_REDIS" option.
|
| The GLIDE client also exposes a handful of Valkey-native options:
|
| VALKEY_READ_FROM primary, prefer_replica, az_affinity, any
| VALKEY_TLS true to enable TLS/SSL for every connection
| VALKEY_AZ_AFFINITY availability zone used when read_from is "az_affinity"
|
| Further GLIDE capabilities (IAM auth, reconnect strategy, client-side
| caching, compression, clustering, and OpenTelemetry) may be enabled via
| the commented options shown below.
|
*/

'valkey' => [

'from_redis' => env('VALKEY_FROM_REDIS', false),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 from_redis placement may be silently ignored by the driver

from_redis lives at the top level of the valkey config array, sibling to client, options, default, and cache. If the GLIDE driver reads driver-level flags from the options sub-array (as most Laravel connection drivers do), this key will never be seen and the fallback behaviour will silently not work. It may belong inside options alongside the other driver flags (use_tls, read_from, etc.), or the driver's config-reading path should be confirmed to look one level up.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this config does or what is it intended for?


'client' => env('VALKEY_CLIENT', 'valkey_glide'),

'options' => [
'cluster' => env('VALKEY_CLUSTER', env('REDIS_CLUSTER', 'valkey')),
'prefix' => env('VALKEY_PREFIX', env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-')),
'persistent' => env('VALKEY_PERSISTENT', env('REDIS_PERSISTENT', false)),
'use_tls' => env('VALKEY_TLS', false),
'read_from' => env('VALKEY_READ_FROM', 'primary'),
'az_affinity' => env('VALKEY_AZ_AFFINITY'),
],

'default' => [
'url' => env('VALKEY_URL', env('REDIS_URL')),
'host' => env('VALKEY_HOST', env('REDIS_HOST', '127.0.0.1')),
'username' => env('VALKEY_USERNAME', env('REDIS_USERNAME')),
'password' => env('VALKEY_PASSWORD', env('REDIS_PASSWORD')),
'port' => env('VALKEY_PORT', env('REDIS_PORT', '6379')),
'database' => env('VALKEY_DB', env('REDIS_DB', '0')),
'max_retries' => env('VALKEY_MAX_RETRIES', env('REDIS_MAX_RETRIES', 3)),
'backoff_algorithm' => env('VALKEY_BACKOFF_ALGORITHM', env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter')),
'backoff_base' => env('VALKEY_BACKOFF_BASE', env('REDIS_BACKOFF_BASE', 100)),
'backoff_cap' => env('VALKEY_BACKOFF_CAP', env('REDIS_BACKOFF_CAP', 1000)),
],

'cache' => [
'url' => env('VALKEY_URL', env('REDIS_URL')),
'host' => env('VALKEY_HOST', env('REDIS_HOST', '127.0.0.1')),
'username' => env('VALKEY_USERNAME', env('REDIS_USERNAME')),
'password' => env('VALKEY_PASSWORD', env('REDIS_PASSWORD')),
'port' => env('VALKEY_PORT', env('REDIS_PORT', '6379')),
'database' => env('VALKEY_CACHE_DB', env('REDIS_CACHE_DB', '1')),
'max_retries' => env('VALKEY_MAX_RETRIES', env('REDIS_MAX_RETRIES', 3)),
'backoff_algorithm' => env('VALKEY_BACKOFF_ALGORITHM', env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter')),
'backoff_base' => env('VALKEY_BACKOFF_BASE', env('REDIS_BACKOFF_BASE', 100)),
'backoff_cap' => env('VALKEY_BACKOFF_CAP', env('REDIS_BACKOFF_CAP', 1000)),
],

// The options below expose additional GLIDE capabilities. They are
// optional and disabled by default — uncomment any you wish to use.

// 'request_timeout' => env('VALKEY_REQUEST_TIMEOUT', 250),
// 'connection_timeout' => env('VALKEY_CONNECTION_TIMEOUT', 250),
// 'client_name' => env('VALKEY_CLIENT_NAME'),
// 'lazy_connect' => env('VALKEY_LAZY_CONNECT', false),
// 'inflight_requests_limit' => env('VALKEY_INFLIGHT_LIMIT', 1000),
// 'register_phpredis_aliases' => env('VALKEY_REGISTER_ALIASES', true),

// AWS ElastiCache / MemoryDB IAM authentication.
// 'iam_config' => null,

// Reconnect / backoff strategy.
// 'reconnect_strategy' => [
// 'num_of_retries' => env('VALKEY_RECONNECT_RETRIES', 3),
// 'factor' => env('VALKEY_RECONNECT_FACTOR', 2),
// 'exponent_base' => env('VALKEY_RECONNECT_EXP_BASE', 2),
// ],

// Client-side caching (server-assisted invalidation).
// 'client_side_cache' => [
// 'enabled' => env('VALKEY_CSC_ENABLED', false),
// 'max_size' => env('VALKEY_CSC_MAX_SIZE', 10000),
// ],

// Native payload compression (experimental).
// 'compression' => [
// 'enabled' => env('VALKEY_COMPRESSION', false),
// 'algorithm' => env('VALKEY_COMPRESSION_ALGO', 'lz4'),
// ],

// Cluster node definitions for multi-node deployments.
// 'clusters' => [
// 'default' => [
// ['host' => '10.0.0.1', 'port' => 7000],
// ['host' => '10.0.0.2', 'port' => 7001],
// ['host' => '10.0.0.3', 'port' => 7002],
// ],
// 'options' => [
// 'read_from' => 'prefer_replica',
// 'use_tls' => true,
// 'az_affinity' => 'us-east-1a',
// ],
// ],

// OpenTelemetry tracing and metrics export.
// 'otel' => [
// 'enabled' => env('VALKEY_OTEL_ENABLED', false),
// 'endpoint' => env('VALKEY_OTEL_ENDPOINT'),
// 'traces' => ['enabled' => true, 'sample_percentage' => env('VALKEY_OTEL_SAMPLE_PCT', 1)],
// 'metrics' => ['enabled' => true],
// 'flush_interval_ms' => env('VALKEY_OTEL_FLUSH_MS', 5000),
// ],

],

];
71 changes: 51 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ services:
ports:
- "11211:11211"
restart: always
mysql:
image: mysql/mysql-server:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_ROOT_PASSWORD: ""
MYSQL_DATABASE: "forge"
MYSQL_ROOT_HOST: "%"
ports:
- "3306:3306"
restart: always
# postgres:
# image: postgres:15
# mysql:
# image: mysql/mysql-server:5.7
# environment:
# POSTGRES_PASSWORD: "secret"
# POSTGRES_DB: "forge"
# MYSQL_ALLOW_EMPTY_PASSWORD: 1
# MYSQL_ROOT_PASSWORD: ""
# MYSQL_DATABASE: "forge"
# MYSQL_ROOT_HOST: "%"
# ports:
# - "5432:5432"
# - "3306:3306"
# restart: always
postgres:
image: postgres:18-alpine
environment:
POSTGRES_PASSWORD: "secret"
POSTGRES_DB: "forge"
ports:
- "5432:5432"
restart: always
Comment on lines +23 to +30

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Unrelated service swap from MySQL to PostgreSQL

This PR's stated scope is adding Valkey support, but it also replaces the active MySQL service with PostgreSQL. Contributors relying on this docker-compose.yml for MySQL-based development workflows will find their database service no longer starts by default. The MySQL-to-PostgreSQL switch deserves its own PR or at minimum a note in the PR description explaining why it is bundled here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ditto

Any reason why we are modifying the defaults? We should be making additive changes not forcing to use Postgres over Mysql, same for Valkey and Redis

# mariadb:
# image: mariadb:11
# environment:
Expand All @@ -46,11 +46,11 @@ services:
# ports:
# - "1433:1433"
# restart: always
redis:
image: redis:7.0-alpine
ports:
- "6379:6379"
restart: always
# redis:
# image: redis:7.0-alpine
# ports:
# - "6379:6379"
# restart: always
# redis-cluster-0:
# image: redis:7.0-alpine
# ports:
Expand All @@ -77,3 +77,34 @@ services:
# - redis-cluster-2
# command: sh -c 'redis-cli --cluster create redis-cluster-0:7000 redis-cluster-1:7001 redis-cluster-2:7002 --cluster-replicas 0 --cluster-yes || true'
# restart: no
valkey:
image: valkey/valkey:9-alpine
ports:
- "6380:6379"
restart: always
Comment on lines +80 to +84

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== docker-compose.yml excerpt ==\n'
nl -ba docker-compose.yml | sed -n '70,95p'

printf '\n== config/database.php excerpt ==\n'
nl -ba config/database.php | sed -n '1,220p'

printf '\n== valkey/redis env references ==\n'
rg -n "VALKEY_PORT|REDIS_PORT|valkey|redis" .env* config docker-compose.yml README* -g '!vendor'

Repository: opensource-for-valkey/php-laravel-framework

Length of output: 255


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== docker-compose.yml excerpt ==\n'
awk 'NR>=70 && NR<=95 { printf "%4d  %s\n", NR, $0 }' docker-compose.yml

printf '\n== config/database.php excerpt ==\n'
awk 'NR>=1 && NR<=220 { printf "%4d  %s\n", NR, $0 }' config/database.php

printf '\n== valkey/redis env references ==\n'
rg -n "VALKEY_PORT|REDIS_PORT|valkey|redis" .env* config docker-compose.yml README* -g '!vendor'

Repository: opensource-for-valkey/php-laravel-framework

Length of output: 14969


Align the Valkey host port with the default config
The service publishes 6380:6379, but config/database.php still falls back to REDIS_PORT=6379 for Valkey. Host-side connections will miss unless VALKEY_PORT=6380 is set; either map 6379:6379 or document the override.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker-compose.yml` around lines 80 - 84, The Valkey service is exposing host
port 6380 while the default Redis/Valkey config still assumes 6379, so update
the docker-compose Valkey mapping to match the default port or make the port
override explicit in config/database.php. Use the valkey service definition and
the database configuration defaults together to keep host-side connections
working without requiring extra environment setup.

Comment on lines +80 to +84

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Port mismatch between docker service and config defaults

The valkey service exposes host port 6380 ("6380:6379"), but config/database.php defaults VALKEY_PORT to 6379. A developer who runs docker-compose up and relies on the default env values will get a connection refused error — the framework tries :6379 while Valkey listens on host :6380. Either map the container to the same host port ("6379:6379") so the config defaults work without any extra env, or document that VALKEY_PORT=6380 must be set when using this compose file.

# valkey-cluster-0:
# image: valkey/valkey:9-alpine
# ports:
# - "7100:7100"
# restart: always
# command: valkey-server --port 7100 --appendonly yes --cluster-enabled yes
# valkey-cluster-1:
# image: valkey/valkey:9-alpine
# ports:
# - "7101:7101"
# restart: always
# command: valkey-server --port 7101 --appendonly yes --cluster-enabled yes
# valkey-cluster-2:
# image: valkey/valkey:9-alpine
# ports:
# - "7102:7102"
# restart: always
# command: valkey-server --port 7102 --appendonly yes --cluster-enabled yes
# valkey-cluster-creator:
# image: valkey/valkey:9-alpine
# depends_on:
# - valkey-cluster-0
# - valkey-cluster-1
# - valkey-cluster-2
# command: sh -c 'valkey-cli --cluster create valkey-cluster-0:7100 valkey-cluster-1:7101 valkey-cluster-2:7102 --cluster-replicas 0 --cluster-yes || true'
# restart: no