Where to put User model?
I'm working on simple PHP framework which follows MVC best practices. Core classes (config, request, response, router, dispatcher, db etc) are stored in registry which is also some kind of DIC.
The question is - where to put models which also is needed throughout application? For example User model.
One more question regarding this - User model will be created on login. When there is no logged in user, should User model be null or what? I don't l开发者_Python百科ike this because is_null() checks will be needed in many places.
MVC design patter is quite straight forward look and the documentation of major frameworks like Codeigniter,Kohana or even kissmvc which is simple and will help u identify the structure of the framework.
And regarding the login question , You can have a separate class to manage the sessions and use this to set if a user model was created not the object it self. You can getter better idea if you read the Zend_Auth Manual. Its simple to understand.
精彩评论