SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2014
    Posts
    37
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    MVC, repositores and interfaces.

    Hi guys I am trying to learn MVC and correct usage of interfaces and repositories. Would this be a good start? Is it a good design?

    What is the next step to improve this? Thank you.

    this link.

    Many thanks fellows

  2. #2
    SitePoint Guru
    Join Date
    Nov 2003
    Location
    Huntsville AL
    Posts
    702
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    Having the controller access the database via a repository is a good thing.

    Your 'members_model' seems superfluous. The repository should be the one to access the database. No need for another layer.

    PHP Code:
    // In your controller
    $members $this->memberRepository->finadAll();
    foreach 
    $members as $member) ...

    // Also
    $memberId 42;
    $member $this->memberRepository->find($memberId); 
    You might be confusing your members_model with the domain model. The domain model (if you have one) would consist of the $member entity with no database specific code.

    If you have not already, you might take a look at Doctrine 2.

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2014
    Posts
    37
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi

    1 - I have been trying to understand the layers but haven't been able to yet! So when you say domain model I don't really follow. Would you please explain that via my graph?

    2 - The other thing that I wonder is what is the best ways to handle errors. Everything from sql failure to failure in controller, repository, interface or the model. Do you mind showing me where is the best place to do that?

    3 - By looking at this, how much do you think I understand about OOP? Is it a good idea to move to a freamework? Or not just yet? It sounds like an ocean, not sure where I am ni the level of progress lol

    Thank you


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •