Store Notification Messages |
Hi,
Not sure if this is the best place to post this, but here goes. I'd like to keep all of my applications notification messages in one spot for easier maintenance. Right now I've created a library Messages and store all of the messages as constants, so then I can refer to them as Message::ERROR_WITH_SUBMISSION in the code, for example.Is this an accepted way? Or should I be adding these types of messages be added to the constants.php file? How would you go about this? Thank you in advance, Chris
IMO, the library is a better solution than using constants.php mostly because the library provides a clear separation of concerns. Even with the library I would probably use a separate file that contains the actual constant definitions.
An alternative approach might be to use a config file where the messages are accessed by using keys into the config array. |
Welcome Guest, Not a member yet? Register Sign In |