class \mpf\base\Config

class \mpf\base\Config

Inheritance -
Implements -
Uses -
Childs -
Available since version  0.1
Source Code

This class doesn't extend any \mpf\base\Object or any other class as it should be the first class loaded when any type of application is executed.

When it's instantiated it should receive a single parameter that contains a list of options used by all framework classes. If instead of a list, a string is sent then it will load it as a file and read the config options from there.

That list is usually read from php/config/ folder. By default each app has at least 2 config files there:

  • - that will return a list of options for console applications
  • - that will return a list of options for websites

There is usually another file there,, that contains config options that is used by both type of apps.

The config folder may contain another file accessmap.php that is used by \mpf\web\AccessMap so you will find more details there. It may also be used to host translations, if the website needs them and if they are set to be saved in file and not in some database.

Config format for the array that is sent to this class should be the following:

 return [
   '\full\ClassName' => [
         'attributeName' => 'attributeValue',
         'secondAttributeName' => 23, // integer value
         'thirdCallableAttribute' => function(){
              return  'My Callable Function';

Some of the default options that are usually fond in are:

 "mpf\\interfaces\\LogAwareObjectInterface" => [
   "loggers" => [
 "mpf\\base\\App" => [
   "title" => "MPF Framework",
   "shortName" => "mpf",
   "cacheEngineClass" => "\\mpf\\datasources\\redis\\Cache"

private string[] $options = []

-no description found-

private static \mpf\base\Config $instance = [mpf\base\Config]

A ling to the current config instance so that it can be called from anywhere using ::get() method.

private string[] $_parents = []

A small cache for same function (example models)


public mixed __construct (null $options = null)

  • $options

    -no description found-

Config constructor. Reads the options from file or from the variable.

public static \mpf\base\Config get ()

Return a link to current config class;

public string[] forClass (string $className)

  • $className

    -no description found-

Returns config for a specific class. It will also check class parents and add extra config for each of them.

private string[] getParents (string $name)

  • $name

    -no description found-

Get all parent class and implemented interfaces for selected class;

public \mpf\base\Config set (string $className, mixed $values)

  • $className

    -no description found-

  • $values

    -no description found-

Update config for a specified class.