Open samsong opened 3 years ago
If it isn't changed to add support for an empty, then how do we write an empty config file?
Hi @samsong, thanks for opening the issue. I think that this one can be fixed on your side, ensuring that the file exists and creating it if it doesn't. @filips123, what do you think?
Hi @samsong, thanks for opening the issue. I think that this one can be fixed on your side, ensuring that the file exists and creating it if it doesn't. @filips123, what do you think?
Yea, I needed to write a blank json “{}” file. Just creating the file (touch filename) isn’t enough. Seems odd it doesn’t create the file if the app has permission. Seems it requires all apps to catch “file doesn’t exist” and create the blank json to try again?
code:
$conf = Config::load('config.json');
^ config.json is a blank file, empty.
result: Fatal error: Uncaught Noodlehaus\Exception\ParseException: Syntax error in config.json:15 Stack trace:
0 \config-2.2.0\vendor\hassankhan\config\src\Parser\Json.php(29): Noodlehaus\Parser\Json->parse(NULL, 'config.json')
1 \config-2.2.0\vendor\hassankhan\config\src\Config.php(114): Noodlehaus\Parser\Json->parseFile('config.json')
2 \config-2.2.0\vendor\hassankhan\config\src\Config.php(79): Noodlehaus\Config->loadFromFile('config.json', Object(Noodlehaus\Parser\Json))
3 \config-2.2.0\vendor\hassankhan\config\src\Config.php(64): Noodlehaus\Config->__construct('config.json', NULL, false)
4 \config-2.2.0\vendor\autoload.php(51): Noodlehaus\Config::load('config.json')
5 {main}
thrown in config.json on line 15