I am debating on using either a configuration.ini
or config.json
for my administration dashboard I am designing. I like that ini
is more for configuration purposes but with todays interest in JSON it seems more logical for the configurations be designed with json in mind.
Question here is should I use json for sure? And secondly I have this hack currently on my configuration.ini
file which prevents the file being seen publicly.
;<?php exit(); __halt_compiler();
; //to stop script execution if not used in our best interest!
; //remember this format
//ini stuff
;?>
I was wondering if I could use this with the json file as well? I haven't tested it just because I didn't want nothing strange completely screwing everything up.As well as a good description as to why this works, now I know this won't work specifically with JSON since the ;
is ini
based commenting so could it be transformed to //
or /**/
for json?
For interest purposes this is currently my admin__autoload.php
page
set_include_path(dirname($_SERVER["DOCUMENT_ROOT"]));
$ini = parse_ini_file("configurations.ini",true);
foreach($ini as $section=>$values) {
foreach($values as $key=>$value ) {
define("__".strtoupper($key)."__",$value);
}
}
spl_autoload_register(function($class) {
if(!file_exists(get_include_path(). DIRECTORY_SEPARATOR .__ADMIN__."classes/{$class}.php")) {
echo get_include_path(). DIRECTORY_SEPARATOR .__ADMIN__."classes/{$class}.php does not exist";
} else {
include_once get_include_path(). DIRECTORY_SEPARATOR .__ADMIN__."classes/{$class}.php";
}
});
__ADMIN__
was created with the foreach loop from my ini file.