SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php|a MVC articles

    It looks like PHP|Architect has decided to release the May 2003 issue of the magazine for free. The lead story for that issue was my "An Introduction to MVC in PHP" article. The next issue's sample article was "Industrial Strength MVC".

    These articles present an overview of the concepts of the Model-View-Controller pattern as it relates to web pages and PHP, and the Industrial Strength MVC article presents a reference application using Phrame for a controller, ADOdb for database abstraction and Smarty based views.

    I wanted to mention these article again since MVC is a hot topic around here, and the "Intro to MVC" article is now available to download for free.

    Thanks.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers... I can never remember the links myself, can you put them in the resources thread for future reference ?

    Thanks

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Elsewhere
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *bump!*

    Excellent articles Jason. I think everyone who is working or struggling with the MVC pattern should read at least the May 2003 article. It's definitely worth the hassle of registration IMO.

    I have one comment/question about the May article: in Figure 2 (page 13) you give an example of a view request, in which you tie the model layer to the view layer, but not to the controller layer. In Figure 3 (page 14), however, you tie the model to the controller, and not to the view (which in this case displays the redirect page after some data processing has occurred).

    Wouldn't you agree that the latter solution is preferable for the first scenario as well? I'm working on my own PHP framework / application (who isn't? ) and I've found that even when users 'merely' request some page to be displayed, whether or not this page is actually returned to the user often depends on business logic (i.e. the model layer). A user may have to login before being allowed to view certain data or pages, for example, or be rejected entirely if his credentials don't grant him access...

    What I really liked about your second article, is the fact that you've included the client's browser in the view layer; something which I think is essential to the understanding of the MVC pattern when used in an environment based on the http protocol (websites using PHP).

    Azmo.

  4. #4
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Going by the MVC Pattern, this...

    view request, in which you tie the model layer to the view layer, but not to the controller layer
    And this...

    you tie the model to the controller, and not to the view
    Is correct I believe ?

    Although I'm having some trouble in respect to the first quote; The View Layer reads from the Model Layer the required models for the view.

    For me, the problem is how the View reads from the Model yes ?

    Umm... I've more reading to do I think

  5. #5
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Azmo
    I have one comment/question about the May article: in Figure 2 (page 13) you give an example of a view request, in which you tie the model layer to the view layer, but not to the controller layer. In Figure 3 (page 14), however, you tie the model to the controller, and not to the view (which in this case displays the redirect page after some data processing has occurred).

    Wouldn't you agree that the latter solution is preferable for the first scenario as well? I'm working on my own PHP framework / application (who isn't? ) and I've found that even when users 'merely' request some page to be displayed, whether or not this page is actually returned to the user often depends on business logic (i.e. the model layer). A user may have to login before being allowed to view certain data or pages, for example, or be rejected entirely if his credentials don't grant him access...
    There are several other people who have commented the same way in other MVC threads here. I am not quite sure what makes my perspective different on this issue. It may be that my views tend to access many methods of several different models, and I have not been creative enought to figure out how to effectivly marshal this need for extracting from many different models, based on the view, without going back to coding a giant switch in somewhere in the controller to gather the data based on the view.

    I felt the solution I showed in the June article was much more elegant (and useful ), i.e. the controller uses a factory to create a concrete view subclass for the current desired view, and each view subclass knows (hard coded) which models to interact and extract the data from.

    One time when this subject came up in a different thread, I said you could think of my view subclasses being an extension of the controller, and only the template rendering being the view, if it makes you feel better

    Thanks for your kind comments, I am glad you found the articles useful.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.


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
  •