I’m trying to come up with the best way to extend some core components. The goal is to put my own layer of functionality on top of the Yii framework.
Let’s say I’d create MyController interface that has to have certain functions which extends the standard CController (CModel, CForm etc… ) and all of my controllers would use this:
Your example is perfectly fine i think, so what is the question actually?
As for other core components of the application: You can extend any of them and configure your own class for them in main.php. See here for a list of all components in an application:
Actually, you did use on of the fundamental OOP things called inheritance. You wrote that you can force Yii to read components outside the protected folder, so I got some questions about it:
What is it for?
Your example is about importing classes from "mystuff" folder inside the "protected" folder (e.g. application.mystuff)…
it’s not really specific to controllers only. i wanna extend models, forms etc. it’s almost like a habit by now the point is, I can keep my code separate in a package or a module, I can put it in a separate SVN branch or even into it’s own SVN repo and implement it in multiple apps (that use the Yii Framework)
I leave it in the protected folder and I also use other config files here that specific to my servers and include it in the index.php.
Just a note: you can also add an alias to define some global include path where you can share components between different applications. See here for an example: