Building a business directory

A question for Walter,

If I was building a Business Directory that could list / sort businesses by category, list things like Business Name, description, contact details etc. Have a search,

From the off only one editor to edit the directory, but later possibly multiple editors.

Would MyActiveRecord be suitable for this?

David


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

MyActiveRecord would be ideal for something like this. I would create a Person model and a Business model, and that way you could assign one or more people as “editors” for the site. Anyone could view a record, but only an editor could modify it or create a new one. (Unless you want to crowd-source the directory, and let anyone make a record, but have the editor approve it for general viewing.) Sorting by any of the attributes that you assign to a model is completely simple in raw MAR, and you can make it even simpler by creating a helper method to automate the process.

Walter

On Aug 6, 2012, at 4:51 PM, David Owen wrote:

A question for Walter,

If I was building a Business Directory that could list / sort businesses by category, list things like Business Name, description, contact details etc. Have a search,

From the off only one editor to edit the directory, but later possibly multiple editors.

Would MyActiveRecord be suitable for this?

David


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

Walter Lee Davis wrote:

Would MyActiveRecord be suitable for this?
Ok, I’m not Walter but I second MAR. I’ve developed with it and it’s great.

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Would it still be OK even if the directory had to have logged in users to read only the directory?

David

On 6 Aug 2012, at 21:58, Walter Lee Davis email@hidden wrote:

MyActiveRecord would be ideal for something like this.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Todd, Walter,

Where would you suggest I research the View, Model, Controller method in conjunction with MAR?

David

On 6 Aug 2012, at 22:02, Todd email@hidden wrote:

Walter Lee Davis wrote:

Would MyActiveRecord be suitable for this?
Ok, I’m not Walter but I second MAR. I’ve developed with it and it’s great.

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

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


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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

Thanks Todd / Walter,

Hopefully I can start remembering names to places in this new landscape.

Walter is the Generate fork of MAR this one? GitHub - walterdavis/myactiverecord: Fork of MyActiveRecord by Jake Grimley

And the screencast here? http://freewaycast.com/screencasts/view/85-generate-a-database-application

I’m right in saying MVC is an easier trip rather than developing your own php familiar bits of code like a login, a search, etc and then stitching them all together into an app.

Not meaning to knock MAR but what’s the difference to using something like http://codeigniter.com with what looks like heaps of documentation?

David

On 7 Aug 2012, at 01:58, Walter Lee Davis wrote:

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.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

On Aug 7, 2012, at 9:57 AM, David Owen wrote:

Walter is the Generate fork of MAR this one? GitHub - walterdavis/myactiverecord: Fork of MyActiveRecord by Jake Grimley

No, look here: GitHub - walterdavis/generate: Lightweight clone of script/generate scaffold for MyActiveRecord and pals

And the screencast here? http://freewaycast.com/screencasts/view/85-generate-a-database-application

Yes.

I’m right in saying MVC is an easier trip rather than developing your own php familiar bits of code like a login, a search, etc and then stitching them all together into an app.

Not meaning to knock MAR but what’s the difference to using something likehttp://codeigniter.com with what looks like heaps of documentation?

By all means, use CI if you want a fully-functioning toolkit out of the box. I really like it, and think it’s one of the nicest iterations of the Rails-in-PHP trope. You are definitely right about the tons of clearly-written documentation. One of the nice things about Generate, though, (to toot my own horn) is that it has a much smaller footprint and includes a generator script. Definitely try CI, do their basic demo application following the guide, and see if you like it. I guarantee there are quite a few less lines of code in my system, and that means less code to have to spelunk through when you can’t get the thing to do what you need.

Walter


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

David Owen wrote:

Not meaning to knock MAR but what’s the difference to using something likehttp://codeigniter.com with what looks like heaps of documentation?
CodeIgniter is a much more comprehensive framework but it’s still based
on the MVC concept of development. I’ve had a play with it a while back
after whetting my appetite with MAR, though I haven’t built anything
with it. It’s very, very nice. If you plan to venture down this PHP road
in earnest I would definitely recommend CI.

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options