Welcome Guest, Not a member yet? Register   Sign In
Make definitions safer
#1

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"))
Reply
#2

Have you modified index.php? The first line in the default CI3.1.0 one defines the ENVIRONMENT constant.
Reply
#3

(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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB