Declaring definitions from configuration files
In configuration files, it is possible to declare definitions from other configuration files.
php
<?php
declare(strict_types=1);
// file: /app/config/services/mix_services.php
use Kaspi\DiContainer\Interfaces\DefinitionsConfiguratorInterface;
return static function (DefinitionsConfiguratorInterface $configurator): void {
$configurator->load('/app/config/config_one.php');
if ('STAGES' === getenv('APP_ENV') {
$configurator->loadOverride('/app/config/services_for_stages.php');
}
};load()
The load() method registers definitions from configuration files while tracking the uniqueness of container identifiers [1].
Method signature:
php
\Kaspi\DiContainer\Interfaces\DefinitionsConfiguratorInterface::load(
string $file,
string ...$_
): voidParameters:
$file– the full path to the definitions configuration file.$_– the full path to the definitions configuration file.
loadOverride()
The loadOverride() method registers definitions from configuration files, with the ability to override previously registered definitions that share the same container identifier [1:1].
Method signature:
php
\Kaspi\DiContainer\Interfaces\DefinitionsConfiguratorInterface::loadOverride(
string $file,
string ...$_
): voidParameters:
$file– the full path to the definitions configuration file.$_– the full path to the definitions configuration file.