views:

55

answers:

2

I've got a class Widgets. Widgets are made up of Doohickies. I'm never going to need to access Doohickies directly via url -- they're essentially a private class, only used by Widgets. Where do you put your code to define the Doohicky class? In /app/controllers/doohicky.php? in app/controllers/widget.php? somewhere else? Obviously, the former seems cleaner, but it's not obvious to me how to make the Doohicky class available to Widget.

+1  A: 

It sounds like your Widgets and Doohickies are probably Models in MVC architecture.

In which case, your paths would be:

app/models/widget.php
app/models/doohickies.php
Dolph
Hmm... now I'm having second thoughts about not needing Doohicky to be a controller -- I do need two views of them -- one for output and one for the edit form. I just always feel reluctant to create a view file for what amounts to a single line of html. I'd rather just put it in a method of the model or something. But then I feel impure.
sprugman
Neither controllers nor models should contain a single HTML tag. Only your views should know how to display your models.
Dolph
If you don't want doohickies to be a view then use a simple helper, if that is not enough then a library.
Phil Sturgeon
A: 

I see the question has been answered already, but there are a few things to bear to expand on it.

You could put widgets and doohickies in the libraries folder, if they are there to do a job rather than provide a data service.

Also, take a look at HMVC, which favours the idea that you can have mini-apps that look after various parts of your website (e.g. messages panels, search box/results, doohickies...). This enables you to have smaller view partials dedicated to their widget controllers; and then the main controller calls in widgets but doesn't need knowledge of how they came about.

http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/

Kurucu