diff --git a/bin/plugin b/bin/plugin index 1741ec281..03737ff4f 100755 --- a/bin/plugin +++ b/bin/plugin @@ -21,6 +21,7 @@ use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Grav\Common\Grav; +use Grav\Common\Config\Setup; use Grav\Common\Filesystem\Folder; $autoload = require_once(__DIR__ . '/../vendor/autoload.php'); @@ -37,6 +38,9 @@ if (!file_exists(ROOT_DIR . 'index.php')) { exit('FATAL: Must be run from ROOT directory of Grav!'); } +// Set up environment. +Setup::$environment = 'localhost'; + $grav = Grav::instance(array('loader' => $autoload)); $grav['config']->init(); $grav['streams']; diff --git a/system/src/Grav/Common/Config/Setup.php b/system/src/Grav/Common/Config/Setup.php index 609b0cdcf..c613b9f7b 100644 --- a/system/src/Grav/Common/Config/Setup.php +++ b/system/src/Grav/Common/Config/Setup.php @@ -17,6 +17,8 @@ use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator; class Setup extends Data { + public static $environment; + protected $streams = [ 'system' => [ 'type' => 'ReadOnlyStream', @@ -131,7 +133,7 @@ class Setup extends Data */ public function __construct($container) { - $environment = $container['uri']->environment() ?: 'localhost'; + $environment = static::$environment ?: ($container['uri']->environment() ?: 'localhost'); // Pre-load setup.php which contains our initial configuration. // Configuration may contain dynamic parts, which is why we need to always load it.