Configuration, settings and storage
Handbook · Coverage · Source reference
Pulse has several configuration systems because different values have different owners. Infrastructure credentials belong to the deployment environment. Game settings can belong to database rows. A user's locale belongs to that identity. Start by finding the code that reads a value; there is no universal “database always wins” rule.
Use local setup for initial installation. This chapter explains how configuration reaches runtime behavior and where apparently similar settings differ.
Use the complete per-file configuration catalogue for every declared key, symbolic default, consumer, precedence rule and disclosure classification. Frontend build variables are documented in frontend internals.
Which place owns a value?
| Place | Examples | Reader |
|---|---|---|
backend/.env / process environment |
Database connection, application key, queue backend | Laravel config loading and some direct env() callers |
backend/config/*.php |
Driver defaults, service credentials, plugin paths | config('file.key') |
settings table |
site_name, plugin-owned switches |
SettingService, direct model queries, individual controllers |
email_settings |
Active SMTP/Mailgun transport | EmailSetting::getActive() and applyToConfig() |
| User columns | timezone, locale, bio |
User settings controller/resource |
| Plugin manifest/settings schema | Defaults and admin controls | Plugin instance, registry and settings controller |
| Frontend build environment | API origin and client configuration | Vite build/dev process |
A database row called maintenance_mode is not Laravel's maintenance mode by itself. Likewise a security setting only changes a password rule if the password validator reads that setting. Security describes current hardcoded validation limits.
Read infrastructure settings through config
Inside backend code prefer config('app.name') over repeatedly reading .env. Config files map environment variables into typed values and defaults. Laravel may cache the resolved configuration; edits to .env then require the deployment's configuration refresh process.
For a plugin with ID welcome, put this option in backend/app/Plugins/welcome/config.php. The default plugin provider merges that root file under plugins.welcome:
<?php
return [
'report_limit' => (int) env('WELCOME_REPORT_LIMIT', 25),
];
Its backend consumer reads:
$limit = config('plugins.welcome.report_limit', 25);
Expected: an integer fallback of 25 when that configuration key is absent. The config namespace must actually be registered by the plugin; creating an arbitrary file does not automatically load it. See plugin runtime.
Some current controllers still call env() directly, including defaults for the site name, and health checks read Reverb environment variables. Treat those as existing implementation details rather than a recommended universal pattern.
Configuration file map
All paths below are relative to backend/config/. The reference inventory supplies the full source map.
| File | Responsibility and useful keys |
|---|---|
app.php |
Application name, URL, frontend URL, environment/key |
auth.php |
Default Sanctum guard, core User provider, password broker |
database.php |
Database connections and Redis configuration |
cache.php |
Default cache store and store definitions |
session.php |
Session backend, cookie and lifetime |
queue.php |
Queue connection, retry timing, failed-job backend |
horizon.php |
Redis worker supervisor queues and process limits |
broadcasting.php / reverb.php |
Broadcast transport and websocket server |
filesystems.php |
Local/public/S3/R2 disks and public link |
mail.php / services.php |
Mail transports and external services |
cors.php |
API origins, methods, headers and credential support |
core.php |
Downstream product_providers list; activity_receipt_days (env PULSE_ACTIVITY_RECEIPT_DAYS, default 90, minimum 1), the player.activity receipt window |
There is no checked-in economy.php configuration file. EconomyService optionally reads economy.player_stat_model and defaults to core PlayerStat when that key is null. A non-null override naming a missing class throws; it does not fall back silently. Do not expect an economy settings file to have been published automatically; see economy.
Inspect a file before using an environment variable found in an older guide. .env.example describes a starting environment; it cannot establish the current value in a running process.
Database settings API
Use App\Core\Services\SettingService from trusted backend code:
use App\Core\Services\SettingService;
$settings = app(SettingService::class);
$limit = $settings->get('welcome.report_limit', 25);
This example can go inside a plugin controller/service method. It reads a database-backed value or the supplied fallback. It does not create a setting.
| Public signature | Arguments/defaults | Return and side effect |
|---|---|---|
get(string $key, $default = null) |
Exact key, fallback | Cast row value, cached for 3,600 seconds |
set(string $key, $value, ?string $description = null, string $group = 'general'): Setting |
Value determines type | Upserts row and forgets that key's cache |
has(string $key): bool |
Exact key | Database existence query |
forget(string $key): bool |
Exact key | Deletes row and key cache |
getGroup(string $group): array |
Group name | Fresh database key/value map with casts |
all(): array |
None | All cast values, cached under settings.all for 3,600 seconds |
clearCache(): void |
None | Forgets aggregate and existing per-key setting caches |
Use namespaced keys such as welcome.report_limit to avoid collisions between plugins. set() defaults every write to group general; pass the desired group when grouping matters. A null or empty description does not erase an existing description.
Write a typed setting
Place this inside an authenticated administrative plugin action or a local development test, not a public request handler:
use App\Core\Services\SettingService;
$settings = app(SettingService::class);
$saved = $settings->set(
'welcome.report_limit',
25,
'Maximum entries in the welcome report',
'welcome'
);
$settings->clearCache();
Expected: a Setting with type === 'integer', stored value '25', and group welcome. Later get() returns integer 25. This writes the database; run it only in the intended environment.
Setting model conversions
Setting::setCastedValue($value) sets both type and stored value; it does not save the model itself.
| PHP value | Stored type | Stored representation | Read result |
|---|---|---|---|
| Array | array |
JSON | Decoded array |
| Boolean | boolean |
'1' / '0' |
Boolean |
| Integer | integer |
Decimal string | Integer |
| Float | float |
String | Float |
| Other | string |
Supplied value | Unchanged value |
getCastedValue() also understands explicitly stored json. Unknown types fall back to the raw value. Malformed JSON produces the ordinary json_decode result rather than schema validation.
SettingsController has its own conversion rules, turning numeric/boolean-looking raw strings into JSON numbers and booleans. Its single-setting endpoint accepts types text, number, boolean, json, while Setting::getCastedValue() specifically handles integer and float, not number. Prefer the service for typed backend values and verify the exact API response shape when consuming admin-written rows.
Admin and public routes
The following admin paths are under /api/v1/admin/settings and require Sanctum authentication, a non-banned account, and admin or moderator role in core routes.
| Method/path | Behavior |
|---|---|
GET / |
Flat stored values with controller conversions |
GET /all |
{settings, groups} merged with core/enabled-plugin defaults |
GET /plugin-schema |
Enabled plugins' admin settings groups |
GET /security |
Security defaults/statistics and configured OAuth credentials |
GET /{key} |
Setting row or 404 |
POST / |
Single {key,value,...} setting or bulk flat settings |
PATCH / |
Flat object or legacy settings: [{key,value}] list |
DELETE /{key} |
Deletes row |
POST /oauth/{provider} |
Persists provider client ID/secret/enabled rows |
Use the documented legacy list, not {"settings":{"site_name":"Example"}}: the latter enters the settings-array branch without matching the expected indexed shape and may return success without updating rows.
Admin writes query Setting directly and do not call SettingService::clearCache(). Service reads may therefore remain stale after admin changes. Also set() invalidates its per-key entry but not settings.all; clear the aggregate when writing and consuming both views.
Public GET /api/v1/settings/public returns site_name, registration_enabled, maintenance_mode, default_theme, frontend_url, world_stage_config, the cash display (currency.cash) and guest_play_url. guest_play_url is an admin setting (General → Guest Play Link) for a game page visitors can play without an account; the sign-in page shows Play free now when it is set. Only a same-site path is accepted (one leading slash, never //, plain URL characters), on save and again on output, so a value written straight into the table cannot turn it into a link to another host. A kit may fill it with its own play route, for example /api/plugins/<slug>/play. It uses direct database queries and boolean parsing; it does not return OAuth or mail secrets. Do not expose SettingService::all() through a public plugin endpoint.
Defaults are not persisted rows
SettingsController::allWithDefaults() builds a core general group and groups supplied by enabled plugin instances' getAdminSettings(). Existing stored values override displayed defaults. Group order defaults to 100; core general has order zero.
The core defaults are site name from APP_NAME, registration enabled true, and maintenance false. Plugin schemas may include field labels, type, min/max/step, options and placeholders. These describe controls. A controller handling an action still needs to validate and enforce the actual rule.
Disabling a plugin can remove its settings schema from the admin result without deleting its stored rows. Re-enabling it can reveal the prior values again.
Secrets and precedence exceptions
Setting has no general encryption or hidden-secret behavior. OAuth client secrets saved through settings are ordinary settings values; admin security/index responses can contain them. Limit access to those responses and redact diagnostic exports.
OAuthService considers environment-configured provider client IDs first when deciding whether a provider is configured. It falls back to database oauth_{provider}_client_id and enabled '1'. When applying configuration, a nonempty database client ID overrides runtime service credentials. An empty environment redirect can fall back to /api/v1/oauth/{provider}/callback.
EmailSetting encrypts password and Mailgun secret via Crypt and hides them in model serialization. getActive(): ?self returns the first active row; it does not select a tenant or user. applyToConfig(): void replaces runtime mail configuration for SMTP or Mailgun and the From address/name.
Preserve APP_KEY securely with deployment recovery material. Losing it can make encrypted mail/2FA data unusable. Creating a new application key on an established installation is a data-compatibility change.
Marketplace connection settings API
MarketplaceConnectionSettings reads settings directly, separately from SettingService caching. The administrative HTTP contract validates its request; trusted callers of this service do not receive that validation automatically.
| Method | Actual behavior |
|---|---|
url(): string |
Nonempty marketplace_api_url row wins over plugins.marketplace.url; database failure falls back to config. Trailing slashes are removed |
token(): ?string |
Decrypts a nonempty stored marketplace_api_token; missing row, query error or decryption error falls back to plugins.marketplace.api_token |
isInternalHub(): bool |
Requires plugins.marketplace.internal_hub and exact equality between the normalized current/configured URLs |
public(): array |
Returns api_url, has_api_token, internal_hub, development_mode; does not return the token |
store(string $url, ?string $token, bool $clearToken = false): void |
Stores the trimmed URL; encrypts a nonempty token, preserves the existing token for null/empty input, or deletes it when clearing is requested |
Clearing a stored token can reveal the configured fallback; it does not guarantee no effective token. store() performs separate writes without its own URL validation or transaction. Preserve APP_KEY for encrypted values and restrict callers of these settings.
Filesystems and cloud storage
filesystems.default comes from FILESYSTEM_DISK, default local. Disk paths are different:
| Disk | Location/configuration |
|---|---|
local |
storage/app/private |
public |
storage/app/public, public URL {APP_URL}/storage |
s3 |
AWS access key/secret/region/bucket, optional endpoint/URL/path-style |
r2 |
Cloudflare R2 access key/secret/bucket/endpoint/URL, region auto |
marketplace_packages |
Private storage/app/marketplace/packages by default |
game_assets |
Public storage/app/public/assets by default |
storage:link maps public/storage to storage/app/public. It does not publish the private local disk. Changing a disk selection does not migrate existing files.
CloudStorageService captures the configured default disk at construction. Its methods are disk(?string $name = null): Filesystem, storeAsset(string $path, mixed $content, string $visibility = 'public', ?string $disk = null): string, url(string $path, ?string $disk = null): string, delete(...): bool, exists(...): bool, and checkStorageHealth(?string $disk = null): array.
storeAsset() returns the path after calling put(); disks configured with throw: false can report a failed write without this method checking its boolean return. Verify exists()/read-back for critical assets. Health checking actually writes, reads and deletes a probe file.
Cache, queues and session are independent
CACHE_STORE, QUEUE_CONNECTION and SESSION_DRIVER select different services. A working database API does not prove Redis workers or stateful sessions work. See operations for checks and communication for queued mail/broadcast behavior.
CacheService uses user:{id}, stats:online_users, modules:all, and settings; these are different from SettingService's setting.{key} and settings.all. Its clearAll() calls Cache::flush(). Shared stores need deliberate isolation; flushing is broader than invalidating one plugin value.
warmUp() caches recently active user count and enabled installed-plugin rows. It does not warm every possible settings or player cache. Its result contains success, warmed, and message.
Installer and per-user preferences
InstallerController tests requirements, saves database/settings input, runs migrations/seeders/storage-link steps, creates the first admin and finalizes installation. The storage/installed marker and installer middleware prevent ordinary reinstallation. Do not delete that marker as a general repair technique.
Installation writes environment values and database state; it is not a read-only system check. Use the beginner setup for a fresh local environment, and operations for existing installations.
Per-user PATCH /api/v1/user/profile accepts name, username, bio, timezone, locale and website URL. Those values live on User, not the settings table. The controller validates their string lengths but does not validate timezone identifiers or URL semantics beyond the listed rules. Avatar upload writes the public disk independently of FILESYSTEM_DISK.
Troubleshooting and source map
| Symptom | First source-backed check |
|---|---|
.env edit ignored |
Config cache, process environment and worker lifetime |
| Admin value differs from plugin | Direct query versus cached SettingService result/type |
all() differs from get() |
Aggregate cache invalidation |
| Setting control disappears | Plugin enabled state and getAdminSettings() implementation |
| Avatar URL wrong | Public disk URL and default Storage::url() behavior |
| R2 works but backup is local | Backup controller has a separate local implementation |
| Toggle has no effect | Find the runtime consumer; existence is not enforcement |
Source: backend/config/*, .env.example, app/Core/Models/Setting.php, EmailSetting.php, app/Core/Services/SettingService.php, CacheService.php, CloudStorageService.php, OAuthService.php, controllers Admin/SettingsController, PublicSettingsController, InstallerController, UserSettingsController.
This page verifies configuration paths and current behavior from source. It does not claim that a cloud bucket, SMTP account, provider callback or deployment secret was exercised. Continue with operations and the test guide.