A significant upgrade to the Yii framework—1.1—came out in January, just over a year after the original 1.0 release. I’ve already updated my series on Learning the Yii Framework to make sure it’s technically accurate, but I thought I’d highlight a few of changes in Yii 1.1 here.
One significant change, which I’ll have to address in a separate post, is support for unit-based testing. The concept of unit testing has become more and more popular over the past few years, and has slowly been making its way into PHP development. The premise is simple: as you develop an application, you write a series of tests that evaluate bits of code. With unit testing, you really want to test isolated, atomic parts of an application. One of the many benefits of unit testing is that as your application grows and becomes more complicated, you can quickly apply the established unit tests to insure that the core components are still working as they should. Yii now auto-generates some testing code for you. Again, I’ll try to write up how you’d use unit testing at a later point.
A second change, that’s perhaps more evident, is the creation of an official library of Yii extensions. These are all filed under the Zii heading (i.e., in the framework/zii directory). To start, there’s a group of jQuery User Interface (jui) extensions, plus several for creating data grids and lists. A couple of standard Yii components, like Menu and Portlet, have been moved to Zii, and I like having the breadcrumbs extension in there. I’ll try to write about that separately as well.
Third, Yii now has a form builder. Much like PEAR’s HTML_QuickForm2, Yii’s form builder makes it easier to create and validate forms without lots of redundant code. I think the Yii manual has a fairly good explanation of this, but I’ll write it up separately if people feel there’s the need.
There are also a number of behind-the-scenes changes, especially as to how related Models are fetched using the Active Record Model. In terms of existing code, Yii 1.1 dropped the safeAttributes() method from Models. This is smart, because I for one never fully understood when something should or should not be marked as a safe attribute. Now safe attributes are those that are validated by other Model rules.
Finally, if you’re already using Yii for some projects, here’s what the Yii managers say about using Yii 1.1: If you are already using Yii 1.0 to develop your project which is about half-way done, we suggest you do not upgrade to 1.1 because there are quite some changes that break backward compatibility. If you just started a new project, we recommend you upgrade to 1.1 because it will receive most of our maintenance effort from now on. While we will continue to maintain 1.0, we expect it will only receive bug fixes in future. If you are new to Yii, you should start with 1.1.