Creating a base controller
Permalink
I was just thinking, in a lot of projects I've done where I just used a framework (CakePHP, ASP.NET MVC, whatever), I usually end up creating a base controller (BaseController) and have all of my other controllers extend that. This way if there is anything that all of my controllers will end up needing I can just put it in BaseController.
So I was wondering, in concrete5 where is the best place to put this base controller? Would you add it as a library? I was just wondering if anyone else had ever done this or had an idea of what the best practice would be.
So I was wondering, in concrete5 where is the best place to put this base controller? Would you add it as a library? I was just wondering if anyone else had ever done this or had an idea of what the best practice would be.
I always placed it right in the "controllers" directory of my package. Never thought much about it, just did it because in the c5 core, the base controllers are there as well.
Hm, I was just wondering if this would cause any issues since that is where it looks for controllers for single pages. Is this the way you would recommend doing it then?
Without having done a thorough analysis, I don't see much different, whether it's a library or a controller. I just tend to do what the core does, I kind of look at the core like a "best practice" place.. (Although, I'm aware that there are some legacy things we shouldn't copy)
Okay, cool. I'd say that is probably a good policy. Thanks for the response Remo!
I tend to put base classes and abstract bases in a library, then inherit them into controllers, models or other libraries. I never actually thought of putting them in /controllers, so set my own pattern and just kept on with it :-)