[Solar-talk] Example Solar Code
Andreas Ravnestad
andreas.ravnestad at gmail.com
Sat Mar 17 03:44:57 PDT 2007
Michael Soule wrote:
> I'm getting a little lost in all the abstractions here. I was
> concerned at first that Solar might not be flexible enough to do what
> I need but instead I'm finding it's so flexible that I'm having
> trouble determining the structure of my App. When you guys build a
> site, do you create both a model and a page controller for each
> individual page or do you make one class handle multiple pages by just
> creating several different actions? If I have pages such as Home,
> Categories, Portfolios, Search Results, Login, and Registration...
> should I have a separate page controller for each of those?
>
> --
> mike
Hi!
Yes you should have separate page controller for those :) But that's not
a rule, just a guideline. We all know web development is seldom as
simple as we envision when we start out on an application :)
I usually write my controllers in singular (not plural), most often one
controller corresponding to some model:
Home (or Default)
Category
Portfolio
SearchResult
Login
Register
For each of these I create the controller file + the related
directories. For example, for some application called "Account" with two
controllers (Profile and User), I create the following:
Account/App/Profile.php
Account/App/Profile/Helper
Account/App/Profile/Layout
Account/App/Profile/Locale
Account/App/Profile/View
Account/App/User.php
Account/App/User/Helper
Account/App/User/Layout
Account/App/User/Locale
Account/App/User/View
And also:
Account/App/Helper
Account/App/Layout
Account/App/Locale
Account/App/View
I may have forgotten something, but this is the most important to me :)
In addition to this I usually create default actions for my controllers,
almost exclusively naming them "index". I try to create my controllers
and actions so they will yield urls looking like this:
http://account.something.com/profile/index
http://account.something.com/profile/details/10 (view the details
on account with id 10)
http://account.something.com/user/login
http://account.something.com/user/register
And so on. I hope this was of some help. I'm sure the other app
developers here have their own styles as well :)
-AR
More information about the solar-talk
mailing list