I'm in a bit of a quandary as to where best to store a static JSON file in CodeIgniter. The file is to be read by a model (i.e. via PHP) and should not be publicly available in the browser.
I have tried to treat the file as, variously:
...but CI expects all of those to contain PHP (in the case of the latter, a class.)
Any suggestions on where I should store it?
[NB: clearly I could store it in helpers and just load it manually, rather than $this->load-helper()
, thus bypassing the attempted PHP interpretation, but that's a last resort.]
I do not know what access you/php have outside the webroot. If you do, you could store it there and use the directory_helper
in CI to read it. Also you could technically store the JSON as a variable in PHP.
If it is not very large, I would store it as a variable in a config like json.php and use it from there.