<?php
use Laminas\Config\Config;
use Laminas\Debug\Debug;
$array1 = [
'base' => [
'env' => 'prod',
'path' => '//config1',
'credentials' => [
'user' => 'johnDoe42',
'password' => 'hfvggjihdsc63vg',
],
'val1' => 'config1',
],
];
$array2 = [
'base' => [
'env' => 'dev',
'path' => '//config2',
'credentials' => [
'user' => 'janeDoe42',
'password' => 'abc123',
],
'val2' => 'config2',
],
];
$allowChanges = true;
$config1 = new Config($array1, $allowChanges);
$config2 = new Config($array2);
$config1->merge($config2);
dump($config1->toArray());
^ array:1 [
"base" => array:5 [
"env" => "dev"
"path" => "//config2"
"credentials" => array:2 [
"user" => "janeDoe42"
"password" => "abc123"
]
"val1" => "config1"
"val2" => "config2"
]
]