what would be the correct way to get a json config? PHP: @mkdir($this->getDataFolder());$this->saveDefaultConfig();$this->configPath = $this->getDataFolder() . 'config.json';$file = file_get_contents($this->configPath);$this->config = json_decode($file, true); unset($file); or PHP: $this->config = new Config($this->getDataFolder() . 'config.json', CONFIG::JSON); or is there an easier way?
PHP: $json = new Config($this->getDataFolder() . "config.json", Config::JSON);$config = json_decode(file_get_contents($json), true);
This is wrong. Argument 1 for json_decode must be string, encoded data in json format, however file_get_contents call will return boolean false and raise warning message. Long story short, you can't pass Config object to file_get_contents. By doing Config::save() on config object which has Config::JSON type will decode holding data into json for you! That's why this class exists in first place. "Why you have to reinvent the wheel"? Simply use Config object with json format as you already showed in second example He meant inside. Edit: If you want to decode and save the data manually PHP: file_put_contents("file.json", json_encode($config->getAll()));