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:
Environments and secrets
Per-server values and secrets (the environment, the database, API keys, passwords) are never committed, not even in settings.php. Read them with feggEnv():
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).
<?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';
| Key | Default | Remarks |
|---|---|---|
cms | true | false 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_ip | array() | 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_days | 30 | Days to keep the application log files (0: keep all) |
mail | array('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_headers | array() | 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_only | false | true: send the policy as Content-Security-Policy-Report-Only (reports only, blocks nothing) |
default_language | not set | Language code used when none is detected, e.g. 'ja'. Only for multilingual sites |
support_language | not set | Supported language codes, e.g. array('ja', 'en'). Only for multilingual sites |
basic_auth_scope | 0 | 0: 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_message | not set | Realm shown in the browser's login dialog |
basic_auth_error_message | not set | Text sent with the 401 response when the login fails (default Authorization Required) |
template_dir | site/template, core/template | Template 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_dir | site/data/cache/template | Compiled 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
$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 migrationneither creates nor dropscms_user,cms_fileandcms_image(their rows are kept) and creates no first CMS user;fegg-cli db:schemaleaves 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/
| File | Remarks |
|---|---|
route.php | URL routing (see URL) |
sites.php | The project's sites, one line each (see Sites) |
site_info.php | Site 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.php | Labels for categories and the CMS visibility states. Loaded by the base controller into $this->config['category_info'] |
cms_menu.php | CMS side menu. Add one block per post type |
env.php | Per-server settings and secrets, read with feggEnv(). Not committed; copy env.php.dist (see Environments and secrets) |
database_config.php | Database connection, from feggEnv() (see Database) |
upload_dir.php | Path 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/*.yaml | Table definitions for fegg-cli migration |
define.php | Optional. Project constants, loaded right after the core starts (web and CLI) |
fegg_update.php | Optional. 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.