flexible, configuration driven controllers - design question


I have an app with lots of similar (look & function) controllers, ie 6 forms & 6 list views. I want to prepare one "form controller" and one "list controller" (with views of course) and be able to configure them for handling different data types (books, authors, publishers, collections, albums, etc…).

I would want to avoid design based on a  class and different subclasses, it's too much for this kind of (customized) crud app.

Perfect solution for this would be a conf file with something like



i would like to do this yii-style, so i need to know which place is best for:

  • url to (my configured general) controller mapping

  • this configuration file (and how to read this file from my controller)

best regards,


btw. yii looks very promising


hm, frankly it's not what i'am looking for.

i need a way to make one controller behave like a 6 different controllers (configuration dependent). how to achieve this without subclassing?

according to URL Management guide i can do something like

"book/view/100" map to "mygeneralcontroler/book/view/100" etc. and in "mygeneralcontroler" use some logic to determine which configuration rule is appropriate for handling "book" request. i would like to avoid solution this.

and one more question, where is the best place to put controller config? and how to access it from controller? i would like to have this in global app config

I needed something like this.  What I did is I had a parent controller, and had other controllers inherit from this controller that needed the same logic as it.  The "configurations" were set as class attributes, and overridden in the child controllers as needed.

For instance, there was a $model attribute that defined the model to use.

this is exactly what i want to avoid (making n subclasses).

i would like to have one conf file, in one place, and be able to make new "controllers" by adding new rule to the configuration.

any ideas where to start? i can hack something but i would like to keep this as close to yii idea as possible.

You can configure your controller based on the request in the init() method of controller class. You can store the configuration in a separate PHP file like app config. You will need to set the model class and other relevant properties that you will need to customize for different models.