3 years ago

Best place to put an API file

Posted 3 years ago by KingKunta

Hello everyone. First time poster.

I have this php file, it's a class which has methods to call an API online. Can this just be placed directly under the app dir - where the models also live? Or is this bad practice?

Another related issue is another 'where to put this' type.

There's a join form, which posts to a uri that saves a user to DB, but after saving that, a call to the API has to be made as well. So I could directly call it and put all that logic in the UsersController, but it does not really belong there.

So would it be a better idea to make an APIController that will make use of this API PHP file and do the API calls there, and then extend the UsersController from the APIController?

How would you structure this particular situation?

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