yohns / config
在config文件夹中加载文件,并将其设置为数组以供后续使用。
0.1.0
2024-08-17 23:45 UTC
Requires
- php: ^8.0
README
将所有配置文件放入1个目录中,然后调用该目录,它将加载所有配置文件到变量中
使用composer的自动加载或include路径到Core/Config.php文件
use Yohns\Core\Config; // load directory new Config(__DIR__.'/config'); //later when need variable echo Config::get('siteName', 'c').PHP_EOL .Config::get('users', 'dt').PHP_EOL .Config::get('language', 'l');
示例代码使用此存储库中找到的config/目录。
c参数是config目录中找到的配置文件名称的第一个字母。您可以看到我有db_tables.php
,因为下划线,它将第二个单词的第一个字母添加到键中,使第二个参数为'dt'
,表示data_tables。
config/config.php
<?php return [ 'siteName' => 'Testing' ];