0

I have a question regarding a custom mvc framework. I am a little confused with how I should implement the models portion. I am thinking since doctrine entities will be my models, then I could create another folder named models in my file structure and within this model folder I will have individual files that will perform the crud functionality. The reason I am trying to do my own framework is that I plan to use dojo mvc on the front-end.

for instance my models folder would look like:

models --> users logger blog

and inside say users class some code my look like:

class Users{

    public function getUsers(){ 

          $users = $this->em->getRepository('entities\Users')->findAll();
          echo // the data from 
    } 

    // also there will be setUsers, etc...      
}

Thanks everyone

j0k
  • 22,600
  • 28
  • 79
  • 90
robasc
  • 307
  • 1
  • 5
  • 15
  • Your approach is fine, go for it. Also you should remember to state explicitly the question next time, otherwise angry SO veterans will bash you with "what's the question?" comments :) I'm assuming your question is something along the lines of "is this design sane?". – Mahn Jun 18 '12 at 00:39
  • say, if you have an entry point @ '/' and a sample model/view 'Users'. If you separate as you intend to do (use strtolower or lowerCamelCase perhaps), then you will gain an advantage; when entry point detects it should go '/Users' (sent GET/PUT etc from a dojo mvc store) then Only call require_once("users/model.php"); and a minimum of classes are loaded – mschr Jun 18 '12 at 03:35
  • Yeah .. this topic is missing the "question" part. It's more like: "here is what i have - discuss". – tereško Jun 18 '12 at 15:01

1 Answers1

1

With in the MVC's Model (at least to my comprehension), the Doctrine should be dealing only with information storage and retrieval for Domain Objects.

And, depending on how you actually implement the front-end part, you might have a very thin interface (that's what views and controller provide) over the model layer, which basically just provides REST API.

Materials you might be interested in:

.. added the last two, because your code bit feels a bit off.

Community
  • 1
  • 1
tereško
  • 58,060
  • 25
  • 98
  • 150
  • Thanks teresko for your comprehension of a model. After reading through the post, it brought me back to my original design of a model. My original design was to create a class named models, and within the models class would consist of functions that perform the business CRUD functionality. – robasc Jun 18 '12 at 16:12