Reputation: 65
How to properly create a custom configuration key in zend expressive I tried to create a file custom-config.php in the config/autoload directory but the key is not read by the container
my custom-config.php looks like this
<?php
[
'customkey' => [
'value1' => '1',
'value2' => '2',
],
];
Upvotes: 0
Views: 314
Reputation:
Configuration files are loaded in a specific order. First global.php
, then *.global.php
, local.php
and finally *.local.php
. This way local settings overwrite global settings.
Settings shared between servers go into *.global.php
, sensitive data and local settings in *.local.php
. Local config files are ignored by git.
The default loading behavior is set in config/config.php
if you want to change this.
Your custom config could look like this:
<?php // config/autoload/custom-config.global.php
return [
'dependencies' => [
'invokables' => [
// ...
],
'factories' => [
// ...
],
],
// Prefered format
'vendor' => [
'package' => [
'key' => 'value',
]
],
// Custom package
'custom_package' => [
'value1' => '1',
'value2' => '2',
],
];
Upvotes: 1
Reputation: 69
Besides missing return
statement, as marcosh pointed out, I think additional problem is the filename itself.
It should be something like custom-config.local.php
or custom-config.global.php
.
Upvotes: 1
Reputation: 9008
I think you a missing a return
statement.
Try with
<?php
return [
'customkey' => [
'value1' => '1',
'value2' => '2',
],
];
Upvotes: 2