Skip to content

Commit

Permalink
put path and runmode to env
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohengjin committed Jul 17, 2017
1 parent cec5e2d commit e49bf33
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/Foundation/Core/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ public static function set($key, $value)
self::$data[$key] = $value;
}



}
21 changes: 21 additions & 0 deletions src/Foundation/Core/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static function init($rootPath)
self::setRootPath($rootPath);
self::setOtherPathes();
self::setInConfig();
self::setInEnv();
}

public static function getRootPath()
Expand Down Expand Up @@ -197,4 +198,24 @@ private static function setInConfig()
Config::set(self::MQ_WORKER_PATH_CONFIG_KEY, self::$mqWorkerConfigPath);
Config::set(self::MODULE_CONFIG_PATH_CONFIG_KEY, self::$moduleConfigPath);
}

private static function setInEnv()
{
putenv("path.root=".self::$rootPath);
putenv("path.config=".self::$configPath);
putenv("path.zan=".self::$zanConfigPath);
putenv("path.sql=".self::$sqlPath);
putenv("path.log=".self::$logPath);
putenv("path.cache=".self::$cachePath);
putenv("path.kv=".self::$kvPath);
putenv("path.model=".self::$modelPath);
putenv("path.table=".self::$tablePath);
putenv("path.routing=".self::$routingPath);
putenv("path.middleware=".self::$middlewarePath);
putenv("path.iron=".self::$ironConfigPath);
putenv("path.app=".self::$appConfigPath);
putenv("path.cron=".self::$cronConfigPath);
putenv("path.mqworker=".self::$mqWorkerConfigPath);
putenv("path.module=".self::$moduleConfigPath);
}
}
11 changes: 6 additions & 5 deletions src/Foundation/Core/RunMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static function get()
public static function set($runMode)
{
self::$runMode = $runMode;
putenv("runMode = $runMode");
}

public static function detect()
Expand All @@ -37,29 +38,29 @@ public static function detect()

$envInput = getenv('KDT_RUN_MODE');
if ($envInput !== false) {
self::$runMode = $envInput;
self::set($envInput);
return;
}

$iniInput = get_cfg_var('kdt.RUN_MODE');
if ($iniInput !== false) {
self::$runMode = $iniInput;
self::set($iniInput);
return;
}

$envInput = getenv('ZANPHP_RUN_MODE');
if ($envInput !== false) {
self::$runMode = $envInput;
self::set($envInput);
return;
}

$iniInput = get_cfg_var('zanphp.RUN_MODE');
if ($iniInput !== false) {
self::$runMode = $iniInput;
self::set($iniInput);
return;
}

self::$runMode = 'online';
self::set('online');
}

public static function isOnline()
Expand Down

0 comments on commit e49bf33

Please sign in to comment.