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??
{
public function onUpdate ( $obj )
{
if ( $obj->username == '' )
throw new \Exception('No username');
}
public function onInsert ( $obj )
{
}
}
?>
, 2 . , getters/seters ( ).
, ... . . - :
www/
Controllers/
Models/
Repositories/
Entities/
Views/
"", commit() - .
2- ( ) Entities, Entities...
, .