How to structure MVC models and ORM models

I have some problems getting a good folder structure in my project, and I would like to know what other ways I can use to structure my files.

I am currently working in a folder with MVC shading.

www/
  Controllers/
  Models/
  Views/

Nothing special yet. But I also use the ORM system. With it, I can easily get the "object" from my database, for example:

ORM::load('table');

Now this kind of code should be on the right side of the model? So I would get something like this:

<?php
class userModel
{
    public function getAllUsers ( )
    {
        return ORM::load('table');
    }

    public function getUserById ( $id )
    {
        return ORM::load('table', 'userid=?', array($id));
    }
}
?>

It looks good so far, in my opinion ... But there is one more thing. I can also specify a "model" when using the ORM system. With this model, I can mainly configure validation rules. For instance:

ORM::withModel('authModel');

ORM , , ( ) , .

<?php
class authModel //Or maybe authValidation??
{
    // Method gets automatically triggered when an update is done with the ORM
    public function onUpdate ( $obj )
    {
        if ( $obj->username == '' )
            throw new \Exception('No username');
    }

    public function onInsert ( $obj )
    {
        // Validations here too.
    }
}
?>

, 2 . , getters/seters ( ).

, ... . . - :

www/
  Controllers/
  Models/
    Repositories/
    Entities/
  Views/

"", commit() - .

2- ( ) Entities, Entities...

, .

+3
1

, , , MVC /. , . , , ( " " ).

, , "". , - (, UserModel) ORM, . , .

:

/application
    /modules
        /public
            /controllers
            /templates
         /admin
            /controllers
            /templates
         ....
    /views
    /model
        /logic
        /persistence
        /services
/framework

, /application /views, /templates. , MVC , . , .

: ORM. datamapper , . ORMs . , .. OO.

.. 2

+10

All Articles