I once
promised to compare
Yii with
CodeIgniter .
I think at the moment I have enough Yii enough to adequately compare
two great frameworks
')
Developers
The active developer at the core of Yii is currently alone, but plans to attract
developing community. Wishes, if they are adequate, are taken into account.
CodeIgniter is developed by the company to fit your needs. Proposals for large
kernel changes are most often ignored.
Documentation
The CodeIgniter documentation will probably remain a benchmark for me. 90% of the total
The functional is described quite compactly, in simple language and well decorated.
Written documentation exclusively by developers. Adequate wishes are accepted and
are considered. Translation into Russian was done for quite some time. Highlights everything
still relevant, but some parts need to be updated.
Yii is more complex and young enough. Therefore, the documentation does not cover some
interesting places (however, well described in the API). However, from this
the developer does not suffer: the most typical moments are described, which in most
cases and have to use. Documentation language is more like a scientific (in those
parts of the Russian translation, which I was engaged in, I tried to build sentences
easier). Making a neat, but does not cause emotion as it does
CodeIgniter documentation.
Documentation is written by developers. Wishes are accepted. Translation is carried out
several development teams. This is done centrally using
Svn. Anyone can join the team of translators.
Compatibility
Yii is written in PHP5.2 (it also works with PHP5.3) and does not support PHP4. Used by
quite a lot of new features for PHP5.2. PDO is required for operation.
CodeIgniter is compatible with PHP4 and uses PHP at the level of the fourth version. On PHP5.3 it does not start yet.
Speed
CodeIgniter is known for its ease and speed of work. Yii is also very fast
especially if we consider sufficiently flexible frameworks. On the official website of Yii
There is a
comparison of the speed of work .
Directory structure
The directory structure is configured better 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, the loading of classes is very well done. Something loads automatically
the rest is through $ this-> load. Everything that is specified in
configuration files.
Router
At first glance, the URL construction mechanism in Yii is similar to CI, but it supports such
nice things like disabling default routes and normal GET support.
Controller
For naming, Yii uses MyController vs My in CI,
actionMyCool () against mycool in CI. This solves the problem with duplicate
class names, and open methods often occurring in CI.
In general, in Yii the controller is more flexible.
Out of inconvenience: the parameters passed through the URL must be received from $ _GET, and not
of the parameters of the method, as it was in CI.
Display
View in CodeIgniter frankly weak, though, if you use third-party solutions
(
http://code-igniter.ru/wiki/View ,
http://code-igniter.ru/wiki/View_helper ) all
not so bad.
Yii is very good in this regard. Layouts, nested views, widgets,
there is an API for implementing your template engines (with already implemented “compiling”)
in PHP code.
Model
In CI, the model is directly connected to the database. There are no other models.
In Yii, the model may use ActiveRecord, or it may not work with the database.
Active record
Active Record in CodeIgniter always gave me mixed feelings: on the one hand
it was pleasant 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 a stdClass.
In Yii, the situation is much nicer: AR here supports deferred loading and relationships.
The data is represented by models for which validators can be defined, their methods and
even behavior (about the same as in Doctrine).
Validation of forms
The validator in Yii heads ahead of CodeIgniter. You can use validators
models, there are quite a few built-in validation rules and it is easy to implement
their.
Extensibility
In Yii, you can forget about the CodeIgniter MY_. Everything is done in a normal OOP way.
At the moment in Yii, I have not met a dead-end code that would not break off.
In CI, I have come across such dead ends several times. The solution was
but pretty dirty every time.
Hooks
In CodeIgniter, you can enable a kernel hook mechanism similar to Drupal. In Yii to achieve
do not include anything like the functional: the kernel itself gives quite
many methods for executing your code at certain times.
What is not in Yii
Built-in classes for working with mail, images, FTP, ZIP, Trackback,
scaffolding.
Also in Yii there are no helpers in the form that was in CI, but nothing prohibits them.
implement ... or borrow, for example, from Kohana.
What is not in CI
Good flexible API, console, class generation, flexible rights,
normal cache, models as such, normal implementation of sessions, OOP.
Total
And the result will not be. Everyone chooses the tool himself;)
If I missed something or want to find out how things are with other features in CodeIgniter or Yii - ask questions in the comments.