Skip to main content
Version: Fegg 5.x

Settings

The project's settings in site/config/. Per-server values and secrets (env.php, the test servers' settings, developer mode) are on their own page:

Basic settings​

The defaults are in htdocs/_fegg/core/config/settings.php. Do not edit that file (it is replaced on update). Put the values for your project in htdocs/_fegg/site/config/settings.php.

The core file is loaded first, then the site file. Only the keys the site file sets are changed, so write one key per line and never reassign the whole array ($settings = array(...) would drop the defaults).

htdocs/_fegg/site/config/settings.php
<?php
defined('FEGG_CORE_DIR') || exit;

// Run mode 1: running, empty: under maintenance
$settings['run_mode'] = '1';

// Maintenance page URL
$settings['maintenance_page_url'] = '';

// Developer IP addresses (multiple allowed). Error details only outside production (FEGG_ENV)
$settings['developer_ip'] = array('192.168.65.1', '203.0.113.10');

// Basic authentication scope (0: none, 1: whole site, 2: partial)
#$settings['basic_auth_scope'] = 0;
#$settings['basic_auth_user'] = '';
#$settings['basic_auth_password'] = '';

// HSTS, once the whole site is served over HTTPS
#$settings['hsts'] = 'max-age=31536000';
KeyDefaultRemarks
cmstruefalse for a site without the CMS (see A site without the CMS)
run_mode'1''1': running. Empty: under maintenance. During maintenance every request that does not come from developer_ip is redirected to maintenance_page_url, or gets a short maintenance message when it is empty.
maintenance_page_url''Redirect target during maintenance
developer_iparray()Addresses that can see error details outside production (see Developer mode) and that bypass maintenance
timezone''Time zone of the application, set once at startup. '': FEGG_DEFAULT_TIMEZONE (Asia/Tokyo)
log_level''Lowest level written to the application log (debug, info, notice, warning, error ...). '': warning in production, debug elsewhere. See Log
log_retention_days30Days to keep the application log files (0: keep all)
mailarray('transport' => 'sendmail', 'from' => '', 'from_name' => '')Outgoing mail of Fegg\Tool\Mail, and the sender when send() is given none (see Sender). For SMTP see Mail
security_headersarray()Changes the default security headers: 'Header-Name' => 'value', '' removes one. See Security
hsts''Strict-Transport-Security value sent on HTTPS responses, e.g. 'max-age=31536000'. '': not sent
csp''Content-Security-Policy value. '': not sent
csp_report_onlyfalsetrue: send the policy as Content-Security-Policy-Report-Only (reports only, blocks nothing)
default_languagenot setLanguage code used when none is detected, e.g. 'ja'. Only for multilingual sites
support_languagenot setSupported language codes, e.g. array('ja', 'en'). Only for multilingual sites
basic_auth_scope00: no Basic authentication. 1: every request handled by Fegg, checked before the controller runs. 2: only where the controller calls $this->basicAuth()
basic_auth_user''Basic authentication user
basic_auth_password''Basic authentication password (compared with hash_equals())
basic_auth_messagenot setRealm shown in the browser's login dialog
basic_auth_error_messagenot setText sent with the 401 response when the login fails (default Authorization Required)
template_dirsite/template, core/templateTemplate directories, searched in this order. The tpl/ of the site the URL belongs to is put first (see Sites)
template_ext'tpl'Template file extension
template_cache_dirsite/data/cache/templateCompiled template cache
global_config_dir''Optional directory searched by loadConfig() before site/config/. End it with /

Read a setting from a controller with $this->getSetting().

A site without the CMS​

htdocs/_fegg/site/config/settings.php
$settings['cms'] = false;

With the CMS turned off (Fegg\Cms\Setting):

  • /cms/... (the core's and the project's CMS screens) and the uploads' controller (image sizes and /file/<id>/ under /_fegg/site/up_dir/) answer 404,
  • fegg-cli migration neither creates nor drops cms_user, cms_file and cms_image (their rows are kept) and creates no first CMS user; fegg-cli db:schema leaves them out,
  • fegg-cli user:* refuses to run.

Remove what the project itself has for the CMS: site/config/database/cms_news.yaml and the other post types (migration then drops those tables), site/src/Controller/Cms/, site/template/cms/, the news pages if they show CMS posts, and site/config/cms_menu.php.

Database​

The connection is set in htdocs/_fegg/site/config/database_config.php, which reads FEGG_DB_DSN, FEGG_DB_USER, FEGG_DB_PASSWORD, FEGG_DB_SLAVE_DSN and FEGG_DB_PATH with feggEnv(), so the file is the same on every server. Without settings it is the SQLite file htdocs/_fegg/site/data/db/db.db; if the server allows it, move it outside the document root with FEGG_DB_PATH. For MySQL / MariaDB and master / slave, see Database configuration.

Tables are defined in YAML files (core/config/database/ for the CMS tables, site/config/database/ for the project's tables) and created or changed with ./fegg-cli migration (see fegg-cli). Every table needs the columns valid, created and modified. The files are read by Fegg\Tool\Yaml, which says what it reads.

Other files in site/config/​

FileRemarks
route.phpURL routing (see URL)
sites.phpThe project's sites, one line each (see Sites)
site_info.phpSite title, description, OGP image, picture breakpoints, ... Loaded by the base controller and available in templates as $site. A site's 'info' in sites.php overrides it for that site
category_info.phpLabels for categories and the CMS visibility states. Loaded by the base controller into $this->config['category_info']
cms_menu.phpCMS side menu. Add one block per post type
env.phpPer-server settings and secrets, read with feggEnv(). Not committed; copy env.php.dist (see Environments and secrets)
database_config.phpDatabase connection, from feggEnv() (see Database)
upload_dir.phpPath and URL of the CMS upload directory (htdocs/_fegg/site/up_dir, /_fegg/site/up_dir), and the limits of images in other sizes (image_max, image_cache_max, see Trim)
database/*.yamlTable definitions for fegg-cli migration
define.phpOptional. Project constants, loaded right after the core starts (web and CLI)
fegg_update.phpOptional. Repository used by fegg-cli core:update (see Updating the core)

Any other file in site/config/ can be loaded with $this->loadConfig(). A file with the same name as one in core/config/ (for example validation_error_message.php) replaces the core's file.