简体   繁体   中英

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

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. Also there has been some changes how Laravel treats environments resolution in newer versions. Now, it is checking for the file in root directory with structure .env.{$env_name}.php or .env.php if it is production. Also, it is usefull to take a peak into Config service provider code.

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. Sorry for the disappointment in the conclusion, but i would recommend NOT using a public image when creating a new server... :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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