gpt4 book ai didi

laravel - 如何在 Laravel-4 中包含针对不同环境的自定义配置

转载 作者:行者123 更新时间:2023-12-02 18:36:22 26 4
gpt4 key购买 nike

$env = $app->detectEnvironment(array(

'local' => array('*.local'),

));

原始配置文件可以在我的本地环境中使用,例如database.phpcache.php等。但是我的自定义配置没有在我的本地环境中使用。本地环境。

有没有办法在上面添加我的自定义配置?

最佳答案

首先,您需要定义什么是“本地”环境

$env = $app->detectEnvironment(array(
// everything that contains 'localhost' or '127.0.0.1'
// in URL will be considered to run in local env.
'local' => array('localhost', '127.0.0.1'),

));

然后,您需要在app/config中创建名为local的目录。如果您想覆盖本地环境中的数据库设置。创建文件:app/config/local/database.php 并覆盖此文件中的设置,例如:

'connections' => array(

'mysql' => array(
'username' => 'otherUserName',
'password' => 'otherPassword',
),

),

在此文件中,您不需要指定所有选项,只需指定与生产/基础配置不同的选项。

更多信息见官方docs

关于laravel - 如何在 Laravel-4 中包含针对不同环境的自定义配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17671781/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com