Some Questions I Want To Ask As I Work My Way Though The Definitive Guide

Hi folks,

Just wanted to create a selfish thread where I can ask questions as I go through the definitive guide for what I hope will be the last time (from start to finish anyway). I also hope this thread might help others as a quick reference.

Question 1

Am I correct that Yii pulls all $_GET params and creates named variables from them, which can then be passed directly into the controller? For example…

Yii will parse this URL and create a global variable called $app with a value of ‘forums’, negating the requirement to manual extract the variable from $_GET by additional coding. Is that correct?

It doesn’t make it global as such, but if your action has a matching parameter, it will be populated with the value from the $_GET array. If your action has a parameter that doesn’t have a default value and doesn’t appear in the $_GET array, you’ll get an exception regarding an invalid request.

Thank you.

So you mean it doesn’t make it global to PHP but makes it “global” to the application?

No, it’s not global at all, it’s just available to the action.


Another question I have that it’s probably best to ask here rather than start a new thread…

I have created a jQuery image slider. For the sake of reuse, is this best created as a widget?

Is it considered best-practice to make all URLS case-insensitive?

In terms of avoiding problems with incremented autonumbers in the DB as a result of developing/testing an application, am I correct in thinking there is nothing at all stopping me taking a dump of the DB schema once it is known to be working, deleting the old DB and re-creating from the DB schema dump to reset everything. Is that a common practice?

You could.

You can also see the solutions suggested here:


With regard to URL case sensitivity, for consistency I always keep URL’s completely in lower case using underscore separators if necessary (although I’d prefer to use hyphen). There’s no consensus on best practise as far as the Yii framework is concerned, I suppose the most important thing is that you’re consistent within your own applications.


Regarding creating and deleting models… if I create a new model then decide to delete it, does Yii hold any record of the deleted model?

There’s no record as such, but there will be matching unit test and fixture files in your application’s tests folder.

Thanks mate. I am properly learning unit testing as I go along so I will keep that in mind.