![]() |
Make definitions safer - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: Make definitions safer (/showthread.php?tid=66388) |
Make definitions safer - AmitMY - 10-18-2016 In the index, there is `define("ENVIRONMENT", ....)` However, for my case, and I guess a general case, the first line of the index loads a config file. For me, that config file the ENVIRONMENT definition, so the index throws an error. Solution: Add to index: if(!defined("ENVIRONMENT")) RE: Make definitions safer - ciadmin - 10-18-2016 Have you modified index.php? The first line in the default CI3.1.0 one defines the ENVIRONMENT constant. RE: Make definitions safer - AmitMY - 10-20-2016 (10-18-2016, 11:56 AM)ciadmin Wrote: Have you modified index.php? The first line in the default CI3.1.0 one defines the ENVIRONMENT constant. I did. It seemed like the best place to load my bootstrap file. (only line I added) My bootstrap file does: - Headers setup (allow-origin, allow-methods, allow-headers) - 'die' for OPTIONS requests (preflight requests should not be processed) - Load from a JSON config file that is generated using an init process, and is different between servers, into constant definitions I understand this is not the most ordinary case, because I am basically running a bootstrap code outside/before CI is loading, but I still think, that the case doesn't matter, and like before every function you write `if(!function_exists('is_php'))` that before every definition there would be a `!defined` Specifically for my case, if you are interested to know, I load the settings from a config file, because I bring up machines and replications and stuff with a very simple process, and modifying the JSON file is a piece of cake compared to htaccess, because I am working both with Apache and with nginx. So I wanna be prepared for every scenario |