简体   繁体   English

Laravel环境软件包配置不起作用

[英]Laravel environment package config not working

I am having trouble with package configurations not working in different environments 我在不同环境中无法使用程序包配置时遇到麻烦

Config File: app/config/packages/Anahkiasen/former/config.php 配置文件:app / config / packages / Anahkiasen / former / config.php

This file should be loaded on Every environment but is only being loaded locally. 该文件应在每个环境中加载,但只能在本地加载。 When I put it on my staging server it is loading. 当我将其放在我的登台服务器上时,它正在加载。

Does anyone have any ideas? 有人有什么想法吗?

Current Environment is set by: 当前环境由以下方式设置:

if ( ! isset($testEnvironment)) $testEnvironment = null;
$env = $app->detectEnvironment(function() use ($testEnvironment)
{
    if ($testEnvironment) return $testEnvironment;

    return $_SERVER['APPLICATION_ENV'];
});

You can simplify that with: 您可以使用以下方法简化它:

$env = $app->detectEnvironment(function()
{
    return $_SERVER['APPLICATION_ENV'] ? : "local";
});

$_SERVER is a global, so it is visible globally, and Laravel will check if local (development...) is set by the returning result. $ _SERVER是全局的,因此它在全局可见,Laravel将检查返回结果是否设置了本地(开发...)。 Also there has been some changes how Laravel treats environments resolution in newer versions. Laravel在较新版本中处理环境分辨率的方式也有所变化。 Now, it is checking for the file in root directory with structure .env.{$env_name}.php or .env.php if it is production. 现在,它正在检查根目录中结构为.env。{$ env_name} .php.env.php的 文件 (如果正在生产)。 Also, it is usefull to take a peak into Config service provider code. 此外,深入了解Config服务提供商代码也很有用。

It ended up being something wrong with the server setup. 最终导致服务器设置出现问题。 I am not 100% sure what is was, because I got to the point where i just rebuilt the server and everything magically worked. 我不是100%知道那是什么,因为我已经到了重建服务器的地步,一切都神奇地工作了。 Sorry for the disappointment in the conclusion, but i would recommend NOT using a public image when creating a new server... :) 对不起,结论令人失望,但是我建议在创建新服务器时不要使用公共映像... :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM