[英]How to add custom config file to app/config in Laravel 5?
I want to add custom_config.php
to app/config directory of my Laravel 5 project, but can't find any article explaining this process.我想将
custom_config.php
添加到我的 Laravel 5 项目的app/config目录中,但找不到任何解释此过程的文章。 How is this done?这是怎么做的?
You can easily add a new file to the config folder.您可以轻松地将新文件添加到 config 文件夹。 This file should return configuration values.
此文件应返回配置值。 Check other config files for reference.
检查其他配置文件以供参考。 Say
constants.php
is like so说
constants.php
就是这样
<?php
return array(
'pagination' => array(
'items_per_page' => 10
),
);
You can now access this config file from anywhere by either using the Config Facade or the config()
global function like so您现在可以使用Config Facade 或
config()
全局函数从任何地方访问此配置文件,如下所示
Config::get('constants.pagination.items_per_page');
or或
config('constants.pagination.items_per_page');
ie即
config('file_name.variable_name');
我不知道一个人可能需要创建多少次配置文件,但是这里有一个 Artisan 命令: https : //gist.github.com/jotaelesalinas/eafd831048ca5fb5fba970afd1921f70
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.