请问一下 Laravel 的 config 是怎么实现的?
最近正在研究Laravel
源码,看到这里有点不太清楚是怎么实现的:这个是Foundation/Boostrap/LoadConfiguration.php
这个文件的内容:
protected function getConfigurationFiles(Application $app)
{
$files = [];
$configPath = realpath($app->configPath());
foreach (Finder::create()->files()->name('*.php')->in($configPath) as $file) {
$directory = $this->getNestedDirectory($file, $configPath);
$files[$directory.basename($file->getRealPath(), '.php')] = $file->getRealPath();
}
return $files;
}
执行到这里之后就会开始遍历,调用config
目录的内容,但是具体怎么实现,一时半会还没有想清楚,所以希望有比较熟悉的朋友不吝赐教,多谢!
你可以能需要了解一下
illuminate/config
或者看下我很早写的这篇也许对你有帮助 非 Laravel 项目中集成使用 illuminate/config