Where do I put constants file for Codeigniter (PHP)? -
I have a list of constants (I'm using them as an enum), defining some statements And some only global variables
I think that to put them in the MVC framework, so I can use them for my model and my controller who needs to refer to it?
It should not be left in Config / Stunts.FPP because they should not be called except for this model and its controllers using it.
Editing 1: Explanation
To be more specific, I have my message_model
model and it has a bunch of constants, which I call Message_model_constants.php
. Where should I put message_model_constants.php
and there is a way to include it automatically by the controller that loads message_model
when message_model
Does not (and I do not want to) auto-loaded.
EDIT 2:
I do not really want to automatically weight the constants use the model
Responding to Brennan Nowak, you can simplify your code by loading your configuration, in this file format, you can only control your controllers The model has to be loaded and everything else is done automatically.
Model
Increases the class Message_model model {function __ composition () {origin: model (); $ This- & gt; Load-> Config ('message_model_constants'); } ...
Controller
class extends some_controller controller {function __construct () {parent: Controller (); $ This- & gt; Load-> Model ('message_model'); } ...
As already mentioned, your config files / config / message_model_constants.php
Comments
Post a Comment