Luminova Framework

Base Config

Last updated: 2024-07-25 19:00:37

The base configuration service as the foundation of your application's configuration classes, which are essential for the framework depending on the components utilized in your application. To create a new configuration class, you need to extend and define necessary properties and method as you need.


  • Class namespace: \Luminova\Base\BaseConfig
  • This class is an Abstract class

Usages

Bellow is an example how you can extend the BaseConfig class.

<?php 
namespace App\Utils;

use \luminova\Base\BaseConfig;
class Config extends BaseConfig 
{
    public const MY_VAR = 'var';
}

Now you can import your configuration class anywhere you would like to use it or register in service to make it available anywhere.


Methods

getEnv

An alternative to the global helper function env, the getEnv method allows you to retrieve an environment variable with a specific return type.

public static final getEnv(string $key, mixed $default = null, string|null $return = null): mixed

Parameters:

ParameterTypeDescription
$keystringThe key to retrieve.
$defaultmixedThe default value to return if the key is not found.
$returnstring|nullOptional return types
- [bool, int, float, double, nullable, string]