laravel配置不同环境的配置文件

//在入口bootstrap/App.php中
$env = $app->detectEnvironment(

    function () use ($app) {

        $uname = php_uname('n');

        $environment = 'local';

        switch ($uname) {
            case 'xxx1':
            case 'xxx2':
                $environment = 'production';
                break;
            case 'xxx3':
                $environment = 'testing';
                break;
            default:
                $environment = 'local';
                break;
        }
        putenv("APP_ENV={$environment}");
        (new \Dotenv\Dotenv($app->basePath(), ".env.{$environment}"))->load();
    }
);

  

posted @ 2017-05-15 21:27  Sentiger  阅读(1335)  评论(0编辑  收藏  举报