On May 11, 5:30 pm, keymaster <[email protected]> wrote:
> > PS additional app paths and plugins don't solve the same problem.
>
> Firstly, thanks for these responses. I appreciate it.
>
> Plugins and Additional paths may not solve the same problem, I agree,
> and that's sort of what I am trying to determine, ie. whether I should
> keep all my code as additional paths, or reorganize it as a bunch of
> plugins.
>
>
>
> > I'm kind of scared what you've been up to if for you they are
> > interchangable.
>
> I have two main directories parallel to app/ called base_cms/ and
> base_ecommerce/ , each containing several subfolders, as follows:
>
> app/
>
> base_cms/
> ---------- accounts/
> ---------- addresses/
> ---------- admin_panel/
> ---------- articles/
> ---------- catalog/
> ---------- configs/
> ---------- filters/
> ---------- comments/
> ---------- images/
> ---------- sitemaps/
>
> base_ecommerce/
> ---------- coupons/
> ---------- orders/
> ---------- partners/
> ---------- payments/
> ---------- products/
> ---------- shipping/
>
> cake/
> vendors/
I also used to (e.g. MiBase) do this and as I mentioned/implied in
some circumstances still do (but not instead of using plugins).
>
> Each of the subfolders contains one or even several base controllers,
> components, models, behaviors, views, elements, helpers, etc. as a
> group of closely knit functionality. All these files are base classes,
> so they can (and are) extended at the app level to build any app for
> any client.
>
> For example, the accounts subfolder contains the base model classes:
> BaseAccount, BaseAcountGroup, BaseAccountProfile, BaseAccountAddress,
> etc. and all it's associated base controllers, views, elements,
> behaviors, etc. I also have child Account, AccountGroup,
> AccountProfile, AccountAddress models in the base accounts folder,
> which are simple empty extensions of their Base parent files, and are
> the files cake instantiates.
>
> So in base_cms/accounts/:
>
> BaseAccount extends AppModel - full of code.
> Account extends BaseAccount - empty.
You should really have there (or equivalent)
Account extends AppModel {
var $actsAs = array(
// behavior with all public methods/functionality that currently
exist in BaseAccount.
'Cms.Account' => array(...)
)
}
>
> To override at app/ level for any client, I copy Account.php to app
> level and have:
> Account extends BaseAccount - override whatever functionality I want.
Whenever you use copy and paste - IME you're on the road to
maintainence hell. As has no doubt happened in the past 3 years -
what do you do when you update the base model - and you want/need the
update in your overriden (and therefore disassociated) model in a
client project?
OR
what if a client doesn't want something that he's inheriting at all.
>
> The app/Account.php is chosen by cake over the base_cms/accounts/
> Account.php due to search path ordering.
>
> When a new customer comes along, I add his unique code to app/, and
> just extend/override much of the stuff in my base_cms/ and
> base_ecommerce/ folders.
>
> At the time I started this, it was not even possible for an app to
> access a plugin's model, let alone have one plugin access another
> plugin's models, so I took the additional paths approach.
>
> It may be it is still the correct approach, and plugin usage should be
> limited to app independant code. That's fine.
The main benefit of plugins is that you can share the same code across
different apps. e.g. you could create an accounting plugin and /
outside/ of these 2 projects use it.
>From what you describe I'd:
* move model code into behaviors
* possibly do the same with controllers to components (especially if
you've got a fat app controller or lots of protected/private
controller functions)
* create a plugin for each blob of atomic functionality (which most
likely means folders you mentioned above) - if you deem it appropriate
to do so.
To me the first 2 points are more important than where your files are
(which is essentially almost all it boils down to)
hth,
AD
>
> It's now more than 3 years later,
I think you only just missed plugins being easy to use. your post is
really about 1.2.0 or before.
> plugins are more powerful and
> integrateable into the main app, so I was exploring whether my current
> architecture is still correct, or I should be considering using
> plugins instead of my current subfolder strategy.
Try thinking about whatever development problems you've faced over the
years working on this (and other?) apps - would plugins have helped
you. I bet they would (if nothing else because it's a lot easier to
test an isolated plugin than a mammoth of an application).
hth,
AD
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en