Comparison of Yii with CodeIgniter
Somehow I promised to compare Yii with CodeIgniter .
I think that at the moment I’ve tried Yii enough to adequately compare
two great frameworks.
The active developer at the core of Yii is currently the only one, but plans to attract
community development. Wishes, if adequate, are taken into account.
CodeIgniter is developed by the company to fit your needs. Proposals for major
changes in the kernel are most often ignored.
The CodeIgniter documentation will probably remain the benchmark for me. 90% of all the
functionality is described quite compactly, in simple language and perfectly decorated.
The documentation is written exclusively by developers. Adequate wishes are accepted and
considered. Translation into Russian has been done for quite some time. Highlights are still
relevant, but some parts need to be updated.
Yii is more complex and fairly young. Therefore, the documentation does not cover some
interesting places (however, well described in the API). Nevertheless, the
developer does not suffer from this : the most typical moments are described, which in most
cases will have to be used. The documentation language is more like a scientific language (in those
parts of the Russian translation, which I was engaged in, I tried to build sentences
easier). The design is neat, but does not cause emotion, as the
CodeIgniter documentation does .
The documentation is written by developers. Wishes are accepted. Translation is carried out by
several development teams. This is done centrally using
SVN. Anyone can join the translation team.
Yii is written in PHP5.2 (also works with PHP5.3) and does not support PHP4.
Quite a lot of new functionality is used for PHP5.2. For work PDO is necessary.
CodeIgniter is compatible with PHP4 and uses PHP just at the level of the fourth version. On PHP5.3 it does not start yet.
CodeIgniter is known for its lightness and speed. Yii is also very fast,
especially when considering fairly flexible frameworks. On the official website of Yii
there is a comparison of the speed of work .
The directory structure is more configurable than in CI. Probably because in CI
the default structure is clearer and there are not many requests for its cardinal change.
I personally reconfigured Yii to a structure similar to CI.
In CI, class loading is very well done. Something is loaded automatically, the
rest is through $ this-> load. In Yii, everything that is specified in
the configuration files is automatically loaded .
The Yii URL-building mechanism is at first glance similar to CI, but supports such
nice things as disabling default routes and normal GET support.
For naming in Yii, the postfixes MyController versus My in CI,
actionMyCool () versus mycool in CI are used. This solves the problem of duplicate
class names, and public methods that often arise in CI.
In general, in Yii, the controller is more flexible.
From the inconvenience: the parameters passed through the URL have to be obtained from $ _GET, and not
from the method parameters, as it was in CI.
View in CodeIgniter is frankly weak, although using third-party solutions
( http://code-igniter.ru/wiki/View , http://code-igniter.ru/wiki/View_helper ) is
not so bad.
Yii is very good at that. Layouts, nested views, widgets
are supported, there is an API for implementing your own template engines (with already implemented "compilation")
into PHP code.
In CI, the model is directly connected to the database. There are simply no other models.
In Yii, the model may use ActiveRecord, or it may not work with the database.
The Active Record in CodeIgniter always caused me mixed feelings: on the one hand
, it was nice to do some operations, on the other ... in general, the syntax duplicated SQL
without obvious advantages. The result was returned as an array, or as stdClass.
In Yii, the situation is much nicer: AR here supports deferred loading and relationships.
The data is presented by models for which you can define validators, your own methods, and
even behaviors (similar to those in Doctrine).
The Yii validator is ahead of CodeIgniter. You can use
model validators ; there are quite a few built-in validation rules and it’s easy to implement
your own.
You can forget about CodeIgniter's MY_ in Yii. Everything is done in the normal OOP way.
At the moment, in Yii, I have not come across a dead-end code that does not work out to overlap.
In CI, I came across such stub places several times. The solution was,
but each time quite dirty.
CodeIgniter can include a kernel hook mechanism similar to Drupal. In Yii, to achieve
similar functionality, you do not need to include anything: the kernel itself provides quite a
few methods for executing its code at certain points.
Built-in classes for working with mail, images, FTP, ZIP, Trackback,
scaffold.
Also in Yii there are no helpers in the form that was in CI, but nothing prevents them from being
implemented ... or borrowed, for example, from Kohana.
A good flexible API, console, class generation, a flexible system of rights, a
normal cache, models per se, normal implementation of sessions, OOP.
But the result will not be. Everyone chooses the tool themselves;)
If I missed something or have a desire to find out how things are with other features in CodeIgniter or Yii - ask questions in the comments.
I think that at the moment I’ve tried Yii enough to adequately compare
two great frameworks.
Developers
The active developer at the core of Yii is currently the only one, but plans to attract
community development. Wishes, if adequate, are taken into account.
CodeIgniter is developed by the company to fit your needs. Proposals for major
changes in the kernel are most often ignored.
Documentation
The CodeIgniter documentation will probably remain the benchmark for me. 90% of all the
functionality is described quite compactly, in simple language and perfectly decorated.
The documentation is written exclusively by developers. Adequate wishes are accepted and
considered. Translation into Russian has been done for quite some time. Highlights are still
relevant, but some parts need to be updated.
Yii is more complex and fairly young. Therefore, the documentation does not cover some
interesting places (however, well described in the API). Nevertheless, the
developer does not suffer from this : the most typical moments are described, which in most
cases will have to be used. The documentation language is more like a scientific language (in those
parts of the Russian translation, which I was engaged in, I tried to build sentences
easier). The design is neat, but does not cause emotion, as the
CodeIgniter documentation does .
The documentation is written by developers. Wishes are accepted. Translation is carried out by
several development teams. This is done centrally using
SVN. Anyone can join the translation team.
Compatibility
Yii is written in PHP5.2 (also works with PHP5.3) and does not support PHP4.
Quite a lot of new functionality is used for PHP5.2. For work PDO is necessary.
CodeIgniter is compatible with PHP4 and uses PHP just at the level of the fourth version. On PHP5.3 it does not start yet.
Speed
CodeIgniter is known for its lightness and speed. Yii is also very fast,
especially when considering fairly flexible frameworks. On the official website of Yii
there is a comparison of the speed of work .
Directory structure
The directory structure is more configurable than in CI. Probably because in CI
the default structure is clearer and there are not many requests for its cardinal change.
I personally reconfigured Yii to a structure similar to CI.
Autoload
In CI, class loading is very well done. Something is loaded automatically, the
rest is through $ this-> load. In Yii, everything that is specified in
the configuration files is automatically loaded .
Router
The Yii URL-building mechanism is at first glance similar to CI, but supports such
nice things as disabling default routes and normal GET support.
Controller
For naming in Yii, the postfixes MyController versus My in CI,
actionMyCool () versus mycool in CI are used. This solves the problem of duplicate
class names, and public methods that often arise in CI.
In general, in Yii, the controller is more flexible.
From the inconvenience: the parameters passed through the URL have to be obtained from $ _GET, and not
from the method parameters, as it was in CI.
Display
View in CodeIgniter is frankly weak, although using third-party solutions
( http://code-igniter.ru/wiki/View , http://code-igniter.ru/wiki/View_helper ) is
not so bad.
Yii is very good at that. Layouts, nested views, widgets
are supported, there is an API for implementing your own template engines (with already implemented "compilation")
into PHP code.
Model
In CI, the model is directly connected to the database. There are simply no other models.
In Yii, the model may use ActiveRecord, or it may not work with the database.
Active record
The Active Record in CodeIgniter always caused me mixed feelings: on the one hand
, it was nice to do some operations, on the other ... in general, the syntax duplicated SQL
without obvious advantages. The result was returned as an array, or as stdClass.
In Yii, the situation is much nicer: AR here supports deferred loading and relationships.
The data is presented by models for which you can define validators, your own methods, and
even behaviors (similar to those in Doctrine).
Form validation
The Yii validator is ahead of CodeIgniter. You can use
model validators ; there are quite a few built-in validation rules and it’s easy to implement
your own.
Extensibility
You can forget about CodeIgniter's MY_ in Yii. Everything is done in the normal OOP way.
At the moment, in Yii, I have not come across a dead-end code that does not work out to overlap.
In CI, I came across such stub places several times. The solution was,
but each time quite dirty.
Hooks
CodeIgniter can include a kernel hook mechanism similar to Drupal. In Yii, to achieve
similar functionality, you do not need to include anything: the kernel itself provides quite a
few methods for executing its code at certain points.
What is not in Yii
Built-in classes for working with mail, images, FTP, ZIP, Trackback,
scaffold.
Also in Yii there are no helpers in the form that was in CI, but nothing prevents them from being
implemented ... or borrowed, for example, from Kohana.
What is not in CI
A good flexible API, console, class generation, a flexible system of rights, a
normal cache, models per se, normal implementation of sessions, OOP.
Total
But the result will not be. Everyone chooses the tool themselves;)
If I missed something or have a desire to find out how things are with other features in CodeIgniter or Yii - ask questions in the comments.