I would be sure to use the Generate fork of MAR, as it follows the Rails standard quite a bit more closely than the vanilla MAR. There’s a screencast on Freewaycast about it.
Model: the data, and the objects that transact with the data. Basically, you don’t ever touch the raw database for anything. You instantiate or find an object of the class “YourModel” and you read or update the attributes of that object. When you save the object, it will either succeed or fail, and you decide what to do then.
View: takes an object (or an array of objects) and turns it into HTML, XML, Mail, whatever. Your views should be as dumb as possible, with as little logic or other control as possible.
Controller: take a browser request (or API request), decipher it, and turn it into an object or an array of objects, and pass it to the view.
Routing: in classical terms, this is a Front Controller. It takes the browser request and decides what to do with it. The router in Generate-flavored MAR is particularly clever, I am quite proud of it. (I wrote it while waiting for my wife to wake up from surgery several years ago.)
Where I would start in this is to use Generate to build a dummy app, push it to your server, and see how it works. Then start fiddling with it. The way Generate writes an app is designed to give everyone access to everything. But it writes everything in layers – there is a “stub” function for each method in the controller, and they call up the stack to the canonical method in the main MyActionController model. This means that for each of your models (Person, Business, Address) you can customize the getters and setters so that the model will do most of the work for you. When you call save, the model will check to see if your object is valid before saving, and throw an appropriate exception if not.
So if you want to force a user to be logged in before seeing anything, you can do that. FreewayTalk, ActionsForge, FreeCounter, FreewayCast, and bunches and bunches of my client work are all written in MAR. They all have varying degrees of user-login-required behavior. The system is extremely flexible, and once you wrap your head around it, you will find it to be a very speedy way to build apps in PHP.
Most of my new work is in Ruby on Rails these days, and the Generate branch of MAR is designed to ape the conventions of that platform where possible. (It’s strictly speaking impossible to write Rails qua Rails in PHP, because the language doesn’t support the needs of the application, while Ruby makes most of it quite straightforward.)
Walter
On Aug 6, 2012, at 7:51 PM, Todd wrote:
David Owen mailto:email@hidden
August 6, 2012 4:23 PM
Todd, Walter,
Where would you suggest I research the View, Model, Controller method in conjunction with MAR?
Hi Dave,
I don’t know if there is any MAR-specific documentation but the MVC architecture is not unique to MAR. There are many tutorials explaining the basics of what each part is and does, eg, http://net.tutsplus.com/tutorials/other/mvc-for-noobs/. But this might be too basic if you already have a fundamental understanding of the MVC.
Todd
http://xiiro.com
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options