문제

I'm starting to use codeigniter for the first time and starting to plan out the coding structure.

I have a number of 'objects' which are referenced on a regular basis throughout the applications: user, article, photo, comment, forum topic, etc. These objects will do common functions like get/set specific details about a user, article, photo, comment, topic etc. This stuff is generally referenced on pretty much every controller at one point or another.

Where is the correct/best practice way to store these and how?

도움이 되었습니까?

해결책 2

That's exactly how MVC works...

Sounds like you'd create models/libraries for each of your business objects and then either use the config->autoload to include them or load them in your core controller class (application/core/MY_Controller).

다른 팁

In general i would suggest building out your methods in the controller, and then refactor and push the methods to the model. Then refactor within your models. The controller says - Do This and waves its hand like a commander. it does not say how to do it, the 'how' is in the model.

Another suggestion I'm just learning about - is to design and build out the application from the point of view of the User Role - like Admin, Purchaser, Editor, etc. Don't put the tools that are used like CRUD in the center of the app. The app should be driven by what the user needs to do. 'Uncle Bob' Martin has a great quote - if you ask an architect to show you a design for a house, they dont come back with a list of tools like hammer, saw, and tape measure. And the architectural design is not cluttered with a bunch of implementation details. the blueprint - or your object design - is specific only for what is necessary.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top