View stunning SlideShares in full-screen with the new iOS app!Introducing SlideShare for AndroidExplore all your favorite topics in the SlideShare appGet the SlideShare app to Save for Later — even offline
View stunning SlideShares in full-screen with the new Android app!View stunning SlideShares in full-screen with the new iOS app!
Yii Web Programming
easy, efﬁcient and extensible
Jason Ragsdale - 11/17/2008
Yii is a high-performance programming framework for developing Web applications in PHP 5.
It enables maximum reusability in Web programming and can signiﬁcantly accelerate the
development process. The name Yii (pronounced as [i:]) stands for easy, efﬁcient and extensible.
Yii is easy to learn and use. You only need to know PHP and object-oriented programming. You
are not forced to learn a new conﬁguration or templating language.
Yii is extremely fast. Its overhead to applications written on top of it is negligible. As a matter of
fact, it is one of the most efﬁcient PHP frameworks around.
Yii is highly reusable and extensible. Yii is purely object-oriented. Everything in Yii is a self-
contained component which can be conﬁgured, reused or extended easily.
More About Yii
Yii comes with a rich set of features. From MVC, DAO/ActiveRecord, to theming,
internationalization and localization, Yii provides nearly every feature needed by today's Web
2.0 application development.
Yii has very detailed documentation. From the deﬁnitive guide to class reference, Yii has every
information you need to quickly learn and master it.
Yii is carefully designed from the beginning to ﬁt for serious Web application development. It is
neither a byproduct of some project nor a conglomerate of third-party work. It is the result of
the authors' rich experience of Web application development and the investigation and
reﬂection of the most popular Web programming frameworks and applications.
Last but not least, Yii is free! Yii uses the new BSD license, and it also ensures that the third-
party work it integrates with use BSD-compatible licenses. This means it is both ﬁnancially and
lawfully free for you to use Yii to develop either open source or proprietary applications.
Performance of Yii
Yii is a high-performance framework. The table below shows how efﬁcient Yii is when
compared with other popular PHP frameworks. The RPS numbers describe how many requests
an application written in a framework can process per second. The higher the number, the more
efﬁcient the framework is.
RPS RPS with APC
Symfony 1.1.2 20
Zend 1.6.1 38
Prado 3.1.2 19
CodeIgniter 1.6.3 78
CakePHP 1.2.0 56
Yii 1.0 92
Solar 1.0 99
Yii with yiilite 1.0 63
0 125 250 375 500
Performance of Yii
A benchmark application is written for each framework. Each application simply tries to display a string "hello world". Any
additional framework features are disabled to ensure fairness of the comparison. You may download the complete benchmark
applications to verify.
The goal of this benchmarking is to reveal the RPS upper limit (or the minimal overhead) of each framework without using any
additional server caching techniques. Therefore, each application is written such that a single die('hello world'); statement is
placed in the default controller action of each application. We do not invoke the complete view rendering logic of each
framework because that will be slower and will not give us the RPS upper limit. As a matter of fact, for actions responding to
AJAX requests, complete view rendering logic is seldom used.
The RPS numbers were obtained using the ApacheBench tool with the command "ab -t 30 -c 10 URL" (i.e., at currency level 10
running the test for 30 seconds). To get each number, we ﬁrst stop and then start the Apache Web server to avoid interference.
The testing environment is as follows:
* Operating System: Red Hat Enterprise Linux Server release 5.2
* Web Server: Apache httpd 2.0.40
* PHP: 5.2.6, any non-essential extensions are disabled
* CPU: Dual Intel Xeon 3.2GHz
* Main Memory: 2GB
* Hard Drive: 73GB 15K RPM SCSI/SAS HDD
Yii comes with a full stack of features needed by today's Web 2.0 application development.
Below is a short list of these features.
* Model-View-Controller (MVC) design pattern: Yii adopts this proven technique in Web
programming which can better separate logic from presentation.
* Database Access Objects (DAO) and Active Record: Yii allows developers to model
database data in terms of objects and save their effort of writing long and repetitive SQL
* Form input and validation: Yii makes collecting form input extremely easy and safe. Yii
comes with a set of validators which can be used to ensure validity of input data, and it also has
helper methods and widgets to indicate errors when validation fails.
* Web 2.0 widgets: powered by jQuery, Yii comes with a set of Web 2.0 widgets, such as auto-
complete input ﬁeld, treeview, and so on.
* Authentication and authorization: Yii has built-in authentication support. It also supports
authorization via role-based access control (RBAC).
* Theming: it enables change of the outlook of an Yii application instantly.
d and routed to different destinations.
* Web services: Yii supports automatic generation of complex WSDL service speciﬁcations
and management of Web service request handling.
* Internationalization (I18N) and localization (L10N): Yii supports message translation, date
and time formatting, number formatting, and interface localization.
* Layered caching scheme: Yii supports data caching, page caching, fragment caching and
dynamic content. The storage medium of caching can be changed easily without touching the
* Error handling and logging: errors are handled and presented more nicely, and log
messages can be categorized, ﬁltered and routed to different destinations.
* Console applications: Yii provides powerful command line tools to automate generation of
code. It also facilitates development of custom console applications.
* Purely object-oriented: Yii framework sticks to strict OOP paradigm. No global functions
or variables. It is easy to extend Yii and use Yii with other third-party libraries.
* Detailed documentation: every single method or property is clearly documented. A
comprehensive tutorial is also provided together with other minor tutorials.
* Extension library: Yii provides an extension library consisting of user-contributed
components. This makes the above feature list never ending.
Although Yii DAO can handle virtually any database-related task, chances are that we would
spend 90% of our time in writing some SQL statements which perform the common CRUD
(create, read, update and delete) operations. It is also difﬁcult to maintain our code when they
are mixed with SQL statements. To solve these problems, we can use Active Record.
Masked Text Fields
Yii incorporates many ideas and work from other well-known Web programming frameworks
and applications. Below is a short list.
* Prado: This is the major source of ideas for Yii. Yii adopts its component-based and event-
driven programming paradigm, database abstraction layers, modular application architecture,
internationalization and localization, and many others.
* Ruby on Rails: Yii inherits its spirit of conventions over conﬁgurations. Yii also referenced
its implementation of active record design pattern.
* Symfony: Yii referenced its ﬁlter design and plug-in architecture.
* Joomla: Yii referenced its modular design and message translation scheme.
this was a nice presentation but we don't guarantee anything was true, Oh and You can see Alaska form here.