Configuration Methods



Predefined settings in ZN Framework are located in 2 different directories.

Folder: Settings/
Folder: Projects/Any/Config/

You can use the settings in these directories or change the settings. You can also create your own settings.

Priority

If both directories contain files and settings with the same name, priority is important. The order of priority is as follows;

Config/

Settings/

If there is a file with the same name and different settings in both directories, these settings are combined. It is used as if pulling from a single file. If there are settings with the same name, priority is as shown above.

 

 

# Methods


Config::get(string $file, string $configs = NULL) : mixed
Config::set(string $file, mixed $configs = NULL, mixed $settings = NULL) : mixed

 

 

# Get (ZN >= 1.0.0)


It is used to access settings from setting files.

Parameters

string $file File name.
string $config = NULL Config name.
return mixed

Usage

File: Config/Project.php
output( Config::get('Project', 'log') );
createFile => boolean false ( length = 5 ),
fileTime => string '30 day' ( length = 8 ),
$log = Config::get('Project', 'log');
echo $log['fileTime'];
30 day
Call Methods [5.0.0]

It is possible to call up your settings more quickly.

Rule: Config::fileName([string $configName])
output( Config::database() );
output( Config::project('key') );

 

 

# Set [1.0.0]


It is used to change the setting values. This change is not made on the file. Only values that come to the get() method are manipulated.

Parameters

string $file File name.
mixed $config = NULL Config name.
mixed $newConfig = NULL News values.
return mixed

Usage

Config::set('Project', 'log', ['fileTime' => '60 day']);

output(Config::get('General', 'log'));
createFile => boolean false ( length = 5 ),
fileTime => string '60 day' ( length = 8 ),
Call Methods [5.0.0]

It is possible to call up your settings more quickly.

Rule: Config::fileName([mixed $set], [mixed $set])
Config::project(['key' => 'example key']);

output( Config::project('key') );

You can also configure by using the 2nd parameter as below.

Config::project('key', md5('my key'));

output( Config::project('key') );

 

 

# Creating a Configuration File


You may want to create a settings file yourself. You can also use the above 3 directories for this. However, if it is a setting that will cover a single project, it is recommended to do this for the Config/ directory. For this, you need to come to this specified directory and create a php file. You need to define the settings in the file you created, as the example settings below.

File: Config/Example.php
return
[
    'example1' => 'Example Value 1',
    'example2' => 'Example Value 2'
];

After defining it as above, you can call it as follows.

Usage

output(Config::get('Example', 'example1'));
Example Value 1;

Or

echo Config::example('example1');