MVC Structure - API wrappers, object formatters, and general helpers

Posted 1 year ago by PeregrineStudios

Hi all,

I'm having trouble determining exactly how to structure my application. The most common answer is 'whatever suits your needs', but I am interested in the convention. Specifically, there's a few classes I have, that I'm not sure where to put. Consider the following:

Authorize.net PHP SDK - this is composer required as a package. No big deal there.

AuthNet - a library I wrote for my application to encapsulate the basic PHP SDK's functionality into more concise functions - IE, a profile can be created with a single method, rather than five nested object creations (of course, internally it still does that). Would this be a 'service'? A 'library', perhaps? Does the convention even allow for 'libraries'? What exactly defines a 'library' as different from a 'service'?

Undetermined Class Name - another class I'll be writing to handle formatting the response from AuthNet. AuthNet will perform basic tasks like creating customer profiles or creating transactions, but the 'business logic' of organizing that data, returning it in a relevant format, etc. will be handled by this class. Based on my understanding of what constitutes a 'service', this would be a 'service' - which leads me to believe AuthNet would not be a 'service'. Am I mistaken?

Or, to phrase the question another way: I have a class whose sole purpose is API access logic. Constructing the relevant objects if needed, posting, getting, etc. and returning the response. I don't necessarily feel that this constitutes a 'service' but I'm not sure where exactly this would live, if not.

Thoughts?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.