protected static function rebuild($configPath, $environment) { $configFile = new Config(); //loads the framework default $config = Config::loadConfigFile(NS_HOME . Config::CONFIG_FOLDER, Config::makeConfigFileName(Config::DEFAULT_ENVIRONMENT)); //loads the framework default plugins config $config->extendWith(self::loadAllPluginConfig(NS_HOME . 'plugin', Config::DEFAULT_ENVIRONMENT)); //loads the application plugins config $config->extendWith(self::loadAllPluginConfig(APP_HOME . 'plugin', array($environment, Config::DEFAULT_ENVIRONMENT))); //loads the application config $config->extendWith(Config::loadConfigFile($configPath, Config::makeConfigFileName(array($environment, Config::DEFAULT_ENVIRONMENT)))); $configFile->config = $config; if (file_put_contents(self::getCachedConfigFile(), $configFile->__toString()) === false) { throw new ConfigException(ConfigException::CANNOT_WRITE_FILE, sprintf("Failed to write to file %s.", self::getCachedConfigFile())); } // fix the permissions, in case this were written as sudo chmod(self::getCachedConfigFile(), 0664); return $config; }