MVC standard for Controller in codeigniter

Asked

Viewed 129 times

0

I have the following scenario, some models that will be accessed via administration (website) and via client (app), in the administration it will be able to read and write data and the customer only read data.

My question, what is the best way to follow the MVC standard to optimize code (do not repeat)?

Since the administration and client will consume data, being the only difference that one will consume in html and the other json.

I thought to make a controller containing all the communication with the models and one more controller for each purpose (administration and model), these would access the main controller.

That my thinking is correct?

  • The basic answer would be: "Understand the basics of MVC + experience"... Each project is one way, I really think it has frameworks a little better than CI. I think the question is very broad

  • Have you seen HMVC? It might solve for your case.

  • @Marcelodiniz found this idea interesting, I did not know this model

  • then, take a look here, in case you haven’t found né https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

1 answer

1


Danilo, I advise you to add an intermediate layer to receive the business rules. It would be between the Controller and the Model, normally this layer is called Service. So the replication of the code can be up to zero. In addition to a Controller for each communication route. Because one can render the screen is the other returns json format or any other.

  • 1

    You miss this even though I wanted to, I was even thinking about using a framework only for api, in this case Lumen

Browser other questions tagged

You are not signed in. Login or sign up in order to post.