Spoova 2.6 Init
File Configuration
The init core configuration file performs a major role in the way and manner in which the framework responds. In most cases, this file may not be visited often, however, it is a useful feature to be able to configure the project application from the terminal which can save time and make it easier to relate with the project application. The icore/init file is designed to anchor both core and custom configuration keys. This means that aside from the default configuration keys, we can set up several other custom unique keys with their respective values which can later be fetched back through the Init controller class.

Terminal Command
The new terminal command fir configuring the Init file is the initConfig command. The sample syntax below explains how parameters or keys can be defined for the init file.
  php mi initConfig KEY VALUE
                                        
From the sample command above, the initConfig command is first defined after which a custom key and value are defined in the specified order. With the sample command above, the init file resembles the format below:
  KEY: VALUE
                                        
The saved keys and their respective values can be removed by setting the value to a dash character.
  php mi initConfig KEY -
                                        

The Init Class
The Init class was added to help manage the init file. This helps to retrieve values of keys stored in the init file. The class below will retrieve the Init file configuration keys.
  <?php 

  use \spoova\mi\core\classes\Init 
  
  class SomeClass {

      function __construct() {

         // Fetch a key's value from init file
         $mykey = Init::key('KEY');

         // Fetch all keys and their value from init file
         $allKeys = Init::values();

         // Fetch specified keys and their value from init file
         $onlyKeys = Init::values(['KEY1','KEY2']);

      }

  }
                                        
In the sample above, the key's value will be returned based on request. It is important to note that values are stored at runtime to save resources.

Alternating Values
Alternate values can be defined for non existing keys or empty values. This is done by supplying a second parameter for the Init::key() method. This is shown below:
  <?php 

  use \spoova\mi\core\classes\Init  

  class SomeClass {

      function __construct() {

         // Fetch a key or use alternate value
         $mykey = Init::key('KEY', 'alternate_value');

      }

  }
                                        

Setting Values
The best way to set the Init file values is to use the Init::set() method. This is because, values stored at runtime will be updated when this method is employed. This is shown below:
  <?php 

  use \spoova\mi\core\classes\Init 

  class SomeClass {

      function __construct() {

         if(Init::set('KEY','SOME_VALUE')) {

            // key set successfully

         }

      }

  }
                                        

Unsetting Values
The best way to unset a key from the Init file is to call the Init::unset() method. This method can easily remove a single or multiple set of keys. Example is shown below:
  <?php 

  use \spoova\mi\core\classes\Init 

  class SomeClass {

      function __construct() {

         $removeKeys = ['KEY1','KEY2'];
         $removedKeys = Init::unset(['KEY1','KEY2');
         
         if($removeKeys === $removedKeys) {

            // all keys unset successfully

         }

      }

  }
                                        
The init file was designed for custom configurations using the extended functionality of the Filemanger class. While it may be easier to manage the icore/init file though Init class, it is suggested to use this class only when there is a necessity to do so. Developers should bear in mind that other core configuration parameters are stored within the init file.