System settings
At the root of the project there is a folder with config settings files, which contains the following files with settings:
- models.php - active models
- plugins.php - active plugins
- routes.php - routes for linking URLs and templates
- settings.php - general settings
- setup.php - basic settings for running the project, it is recommended to fill in the basic settings in the root file .env
The settings are designed as regular and associated arrays. You can add additional custom settings and they will be available anywhere in the project through the Registry class, based on the Singleton pattern.
Basic settings in the .env file
APP_ENV - development/production mode
APP_DOMAIN - domain name with http(s)
APP_FOLDER - project directory, / - if the project is in the root of the domain
APP_TIMEZONE - time zone
APP_TOKEN - secret key for generating hashes
APP_REGION - localization (en, us, ru, de)
Other settings from the config/setup.php and config/settings.php files
- Build - the number of the current application build, affects the cache update, it is recommended to increase the number by 1 when uploading a new version of the code to the production server.
- DebugPanel - displaying the debug panel in all views.
- AdminFolder - the name of the folder with the administrative panel, to change the folder, you need to change the setting and rename the folder.
- SessionSupport - support for the standard PHP session.
- FilesPath - a folder with user files, also useful methods for working with files are in the sections Special methods and Files and images.
- ModelVersionsLimit - a limit on the number of record versions for all active models. For each model, this parameter can be set individually, for more details, see the section Model settings.
Access to settings
To access settings in models and templates, the Registry class is used, which is available inside all MV components, as well as inside the $mv object. The Registry class uses a single array to store settings, so the names in the .env, settings.php and setup.php files should not overlap.
In model classes, the 'MainPath' value (the URL from the domain root to the project, usually '/' on the production server) is available as the $root_path property, a similar property is also available on the object described in the MV Object section.
//Examples of getting settings from anywhere
Registry :: get('APP_DOMAIN');
//Project file root
Registry :: get('IncludePath');
//Secret key
Registry :: get('APP_TOKEN');
//Maximum file size
Registry :: get('MaxFileSize');
//Inside a model or plugin class
class Articles extends Model
{
...
public function display()
{
...
$html .= Registry :: get('MainPath').'article/'.$row['id'];
//or similar
$html .= $this -> root_path.'article/'.$row['id'];
}
}
//You can add your own settings on the fly and they will be available throughout the project
Registry :: set('MySetting', 57);
Registry :: set('SpecialSetting', ['a', 'b', 'c']);
Previous section
SQLite getting started