For my application bundle, I will need some classes that are neither controllers nor models. For instance, I would like to have a scorecard class that has members such as “skill”, “efficiency”, “beauty”, etc. Also, it may have member method/getters like “meanScore”.
Where would such a class go in the Symfony framework?
I agree with @Gordon that this sounds like a business object. But if you’re sure that it isn’t, your next step is to figure out how you would classify it. Is it a helper? An event listener? A utility class? Once you figure that out, ask yourself: is it specific to a bundle, or are you going to reuse it amongst projects?
Let’s say you decide it’s an event listener and belongs to the bundle. Put it in
MyBundle/EventListener. If it’s a helper, put it inMyBundle/Helper. Now if you plan on reusing it amonst projects (which in this case it actually doesn’t sound like it, but bear with me…) you might be better off creating a place invendorfor it.The important thing to remember is that because Symfony2 is so young, there isn’t really a definitive list of best practices that answer questions like these. Right now it’s kind of up to us to see what works, and what doesn’t. It’s like the wild west 🙂