[英]Using Config helper from within config file
Is it possible to use the config()
helper method within the config/app.php
file its self?? 是否可以在
config/app.php
文件中使用config()
帮助器方法?
I can't seem to get it to work. 我似乎无法正常工作。 It just ignore it.
它只是忽略它。
Example; 例;
return [
'extra' => 'test',
'pages' => [
'one',
'two',
'three',
'demographics',
'results',
config('app.extra')
],
];
....from within the app.php file config('app.extra')
does nothing. .... app.php文件
config('app.extra')
不起作用。
Let's do a little experiment :D 让我们做一个小实验:D
Put three files in your config a.php
, b.php
and c.php
and put these values: 将三个文件放入您的配置
a.php
, b.php
和c.php
,并输入以下值:
a.php: a.php:
<?php
return ['name' => 'a'];
b.php b.php
<?php
return [
'name' => 'b',
'name_of_1' => config('a.name')
'name_of_3' => config('c.name')
];
and c.php 和c.php
<?php
return ['name' => 'c'];
Now from b.php you can access values of a.php but not of c.php 现在从b.php您可以访问a.php的值,但不能访问c.php的值
So... 所以...
dd(config(b.name)) //b
dd(config(b.name_of_1)) //a
dd(config(b.name_of_3)) //null
Conclusion You can only access values of previous config files from one config file. 结论您只能从一个配置文件访问以前的配置文件的值。 (And by previous it means alphabetically)
(以前是按字母顺序)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.