Welcome Guest, Not a member yet? Register   Sign In
Store Notification Messages
#1

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

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




Theme © iAndrew 2016 - Forum software by © MyBB