Configuration & Paths
Default config, overrides, and helpers.
Config sources #
VelvetCMS loads configuration from three locations, in this order:
config/*.php(defaults)user/config/*.php(user overrides)user/tenants/<tenant>/config/*.php(tenant overrides when tenancy is enabled)
Later layers override earlier ones using array_replace_recursive. Override files only need to include the keys you want to change.
Runtime overrides #
You can set values at runtime with config([...]). These changes are in-memory for the current process and do not persist to disk.
config(['app.debug' => true]);
Helpers #
| Helper | Description |
|---|---|
config('app.debug') |
Get configuration value |
base_path('storage') |
Base application path |
content_path('pages') |
Content directory (tenant-aware) |
storage_path('cache') |
Storage directory (tenant-aware) |
view_path('partials') |
Views directory (tenant-aware) |
config_path('app.php') |
Config directory |
public_path('assets') |
Public directory |
Tenancy-aware paths #
When tenancy is enabled, path helpers are automatically scoped to the current tenant:
| Scope | Path |
|---|---|
| Content | user/tenants/<tenant>/content |
| Views | user/tenants/<tenant>/views (when view.path starts with user/) |
| Storage | storage/tenants/<tenant> |
You can resolve tenant roots directly with:
tenant_user_path('content')tenant_storage_path('cache')
Caching config #
Use ./velvet config:cache in production to precompile config into a single file. Clear it with ./velvet config:clear.
When tenancy is enabled, the cache file is stored under the tenant storage root (because storage_path() becomes tenant-aware). If you cache config for multiple tenants, run the command per tenant:
TENANCY_TENANT=acme ./velvet config:cache