NotionCommotion Posted May 27, 2016 Share Posted May 27, 2016 (edited) I have a small configuration file which PHP must be able to read from and write to. Do you recommend using JSON, or using a PHP ini file along with parse_ini_file()? Please explain your reasoning. If JSON, how do you recommend saving and retrieving the data? For instance, an array or object? If an ini file, how do you recommend saving the file? Thanks Edited May 27, 2016 by NotionCommotion Quote Link to comment https://forums.phpfreaks.com/topic/301268-do-you-use-parse_ini_file-or-json_decode-to-store-configuration-files/ Share on other sites More sharing options...
requinix Posted May 27, 2016 Share Posted May 27, 2016 I assume a database is out of the question? JSON is easier to write out again. Associative arrays and objects are the same thing when exported so it only matters how you want to deal with them in the code. Quote Link to comment https://forums.phpfreaks.com/topic/301268-do-you-use-parse_ini_file-or-json_decode-to-store-configuration-files/#findComment-1533278 Share on other sites More sharing options...
NotionCommotion Posted May 27, 2016 Author Share Posted May 27, 2016 I assume a database is out of the question? No, not out of the question. It seems excessive as I will only have one row with 4 columns, but maybe I should use one. Quote Link to comment https://forums.phpfreaks.com/topic/301268-do-you-use-parse_ini_file-or-json_decode-to-store-configuration-files/#findComment-1533280 Share on other sites More sharing options...
Barand Posted May 27, 2016 Share Posted May 27, 2016 OTOH an ini file is easier for the client to maintain manually (php.ini for example) Quote Link to comment https://forums.phpfreaks.com/topic/301268-do-you-use-parse_ini_file-or-json_decode-to-store-configuration-files/#findComment-1533283 Share on other sites More sharing options...
ginerjm Posted May 27, 2016 Share Posted May 27, 2016 Why all the mystery in a simple ini file? Why not a simple text file with a defined format? You want the user to maintain it, so how is it going to get to the server? Email? Ftp? ok. So now it's on the server. Why does it have to be endoded. Why not just like the php.ini file format? Quote Link to comment https://forums.phpfreaks.com/topic/301268-do-you-use-parse_ini_file-or-json_decode-to-store-configuration-files/#findComment-1533285 Share on other sites More sharing options...
requinix Posted May 27, 2016 Share Posted May 27, 2016 So there's that question: Does the file need to be (should it be) human-readable and editable? INIs are easier for that. And at only four values you can just use some simple scheme like ginerjm's simple text file. Quote Link to comment https://forums.phpfreaks.com/topic/301268-do-you-use-parse_ini_file-or-json_decode-to-store-configuration-files/#findComment-1533287 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.