Skip to content

Configuration Reference

All per-app settings live in mvc.config.json, placed next to the app's index.php. The file is generated by mvc create-app and updated by other CLI commands (mvc migrations:enable, mvc auth:enable, etc.).

Full key reference

Key Type Default Description
jsAssetsPath string ./assets/scripts Directory where JS bundles are written, relative to the app root.
cssAssetsPath string ./assets/styles Directory where CSS bundles are written.
mainJsBundler string main.min.js Filename for the minified JS bundle produced by mvc create-bundle. Reference this in production layouts.
mainCssBundler string main.min.css Filename for the minified CSS bundle.
devMainJsBundler string main.js Filename for the unminified JS bundle produced by mvc watch-assets.
devMainCssBundler string main.css Filename for the unminified CSS bundle.
useDevAssets bool false When true, layouts load devMainJsBundler/devMainCssBundler instead of the minified files. Set to true while running mvc watch-assets locally.
assetRoutes array [{"label":"default","js":[...],"css":[...]}] Ordered groups of source files to merge into bundles. See Asset Bundling.
i18nBasePath string ./assets/i18n Directory containing {locale}.json translation files.
migrationsFolderPath string "" Relative path from the app root to the migration module directory. Set by mvc migrations:enable.
migrationsEnabled bool false true when migrations are active. The migration module's index.php enforces this.
backgroundTasksFolderPath string "" Relative path to the BackgroundTasks module. Set by mvc initialize-background-tasks.
backgroundTasksEnabled bool false true after mvc background-tasks:enable. The worker's index.php enforces this.
backgroundTasksPollIntervalSeconds int 0 When > 0, the worker runs in a continuous loop, sleeping this many seconds between batches. When 0, one batch per invocation.
authenticationEnabled bool false true after mvc auth:enable. Used by the entrypoint to conditionally call useAuthentication() / useAuthorization().

Example

{
  "jsAssetsPath": "./assets/scripts",
  "mainJsBundler": "main.min.js",
  "devMainJsBundler": "main.js",
  "cssAssetsPath": "./assets/styles",
  "mainCssBundler": "main.min.css",
  "devMainCssBundler": "main.css",
  "useDevAssets": false,
  "assetRoutes": [
    {
      "label": "base",
      "js": ["assets/scripts/core.js"],
      "css": ["assets/styles/root.css", "assets/styles/layout.css"]
    },
    {
      "label": "dashboard",
      "js": ["assets/scripts/dashboard.js"],
      "css": ["assets/styles/dashboard.css"]
    }
  ],
  "i18nBasePath": "./assets/i18n",
  "migrationsFolderPath": "./Migrations",
  "migrationsEnabled": true,
  "backgroundTasksFolderPath": "./BackgroundTasks",
  "backgroundTasksEnabled": true,
  "backgroundTasksPollIntervalSeconds": 0,
  "authenticationEnabled": true
}

Loading config at runtime

use PhpMvc\Config\MvcConfig;

$config = MvcConfig::load($basePath);

if ($config->isAuthenticationEnabled()) {
    $app->useAuthentication();
    $app->useAuthorization();
}