Tuesday, December 11, 2012

Installing Yii in wamp on Windows 7

Installing Yii in wamp on Windows XP

I was successful in installing Yii  in wamp on Windows XP .
The versions are as follows:
Operating System : Windows XP Professional Version 2002 , Service Pack 2
Apache : 2.2.8
PHP : 5.2.6
MYSQL : 5.0.51b
Yii : 1.1.0 (January 10 2010)
Follow the following steps for installation:
1) Click on “Start”
2) goto “My Computer”
3) Right Click and select Properties
4) You will see “System Properties” window
5)  Select “Advanced”tab
6) In “Advanced” tab, click on “Environment Variables”
7) Select “Path” in “System Variables” section
8) Click on “Edit” on selevtion “Path” in “System Variables” section
9) “Edit System Varibale” window will appear with “Variable name” and “Variable value” fields
10)  Enter “C:\wamp\bin\php\php5.2.6″ at the end without double quotes.
11)  Click on OK, OK and OK.
13) Click on Start > Run > cmd
14) It will take you to the command prompt
15) C:\>cd wamp\www
16) C:\wamp\www>mkdir myYii  (myYii is the name of the application you want)
17) C:\wamp\www>cd yii\framework
18) C:\wamp\www\yii\framework> yiic webapp c:\wamp\www\myYii
Create a Web application under ‘C:\wamp\www\myYii’? [Yes|No] y
mkdir C:/wamp/www/myYii/assets
mkdir C:/wamp/www/myYii/css
generate css/bg.gif
generate css/form.css
generate css/ie.css
generate css/main.css
generate css/print.css
generate css/screen.css
mkdir C:/wamp/www/myYii/images
generate index-test.php
generate index.php
mkdir C:/wamp/www/myYii/protected
generate protected/.htaccess
mkdir C:/wamp/www/myYii/protected/commands
mkdir C:/wamp/www/myYii/protected/commands/shell
mkdir C:/wamp/www/myYii/protected/components
generate protected/components/Controller.php
generate protected/components/UserIdentity.php
mkdir C:/wamp/www/myYii/protected/config
generate protected/config/console.php
generate protected/config/main.php
generate protected/config/test.php
mkdir C:/wamp/www/myYii/protected/controllers
generate protected/controllers/SiteController.php
mkdir C:/wamp/www/myYii/protected/data
generate protected/data/schema.mysql.sql
generate protected/data/schema.sqlite.sql
generate protected/data/testdrive.db
mkdir C:/wamp/www/myYii/protected/extensions
mkdir C:/wamp/www/myYii/protected/messages
mkdir C:/wamp/www/myYii/protected/models
generate protected/models/ContactForm.php
generate protected/models/LoginForm.php
mkdir C:/wamp/www/myYii/protected/runtime
mkdir C:/wamp/www/myYii/protected/tests
generate protected/tests/bootstrap.php
mkdir C:/wamp/www/myYii/protected/tests/fixtures
mkdir C:/wamp/www/myYii/protected/tests/functional
generate protected/tests/functional/SiteTest.php
generate protected/tests/phpunit.xml
mkdir C:/wamp/www/myYii/protected/tests/report
mkdir C:/wamp/www/myYii/protected/tests/unit
generate protected/tests/WebTestCase.php
mkdir C:/wamp/www/myYii/protected/views
mkdir C:/wamp/www/myYii/protected/views/layouts
generate protected/views/layouts/main.php
mkdir C:/wamp/www/myYii/protected/views/site
generate protected/views/site/contact.php
generate protected/views/site/error.php
generate protected/views/site/index.php
generate protected/views/site/login.php
mkdir C:/wamp/www/myYii/protected/views/site/pages
generate protected/views/site/pages/about.php
generate protected/yiic
generate protected/yiic.bat
generate protected/yiic.php
mkdir C:/wamp/www/myYii/themes
mkdir C:/wamp/www/myYii/themes/classic
mkdir C:/wamp/www/myYii/themes/classic/views
generate themes/classic/views/.htaccess
mkdir C:/wamp/www/myYii/themes/classic/views/layouts
mkdir C:/wamp/www/myYii/themes/classic/views/site
mkdir C:/wamp/www/myYii/themes/classic/views/system
Your application has been created successfully under C:\wamp\www\myYii.
Thats all. You are ready to use your application by accessing the URL : http://localhost/myYii/

Wednesday, December 21, 2011

Why Yii is so Fast

Why Yii is so Fast

Yii is so much faster because it is using the lazy loading technique extensively. For example, it does not include a class file until the class is used for the first time; and it does not create an object until the object is accessed for the first time. Other frameworks suffer from the performance hit because they would enable a functionality (e.g. DB connection, user session) no matter it is used or not during a request.

Benchmark Setup

Below we explain how we design the benchmark applications and obtain the above RPS figures.

Benchmark Applications

Since our goal is to compare the minimal overhead of each framework, the benchmark application for each framework should be the simplest one. We choose to display a "Hello World" text string by placing an echo statement in the default action of each application. Any additional framework features (e.g. session) are disabled to ensure fairness of the comparison. To obtain a copy of the benchmark applications, please check out the phpmark project.

Why "Hello World"

We choose to do "Hello World" testing mainly to achieve our goal, i.e., to find out the minimal overhead of each framework. Many people complain that the "Hello World" application is meaningless because a real-world application often needs to deal with more complex tasks, such as database queries. This is not very true. In reality, especially in a large-scale Web 2.0 application, we often encounter scenarios that are very close to "Hello World". For example, an application may need to respond to an AJAX request that should return the current server timestamp; a page has a large portion of its content being cached and an application just needs to fetch the cached content and display it.
Another reason for "Hello World" is because when more complex features (e.g. database queries) are involved, it becomes a very difficult task to ensure the comparison is fair. For example, one framework could be very efficient at performing database queries, but it lacks caching scheme; while another framework is a bit slower with database queries, but it has sophisticated caching feature to help ease the performance hit. There are simply too many factors involved to conduct a fair comparison.

Benchmark Tool and Environment

The RPS numbers were obtained using the ApacheBench tool with the command "ab -t 30 -c 10 URL" (i.e., at concurrency level 10 running the test for 30 seconds). To get the number for each framework, we first stop and then start the Apache Web server to avoid interference. We also run the test application for a few times to "warm up" the testing environment. In the phpmark project, we have a shell script named benchmark.sh to automate the benchmarking procedure.
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
The APC ini settings are as follows:
apc.enabled=1
  apc.shm_segments=1
  apc.optimization=0
  apc.shm_size=32
  apc.ttl=7200
  apc.user_ttl=7200
  apc.num_files_hint=1024
  apc.mmap_file_mask=/tmp/apc.XXXXXX
  apc.enable_cli=1
  apc.cache_by_default=1
  apc.stat=0
 

Features of Yii

Whether you are one developer building a fairly simple Web site, or a team of distributed developers building an extremely complex Web application, using Yii is like augmenting your development team with additional experienced, professional, and efficient resources. All for free!
You can stay focused on the tasks specific to your business requirements, and let Yii provide an implementation strategy for all of the following:
  • Model-View-Controller (MVC) design pattern Yii adopts the proven MVC architecture, which allows for clean separation of concerns (SoC).
  • Database Access Objects (DAO), Query Builder, Active Record, DB Migration Yii allows developers to model database data in terms of objects and avoid the tedium and complexity of writing repetitive SQL statements.
  • Form input and validation Yii makes collecting form input extremely easy and safe. It comes with a set of validators as well as numerous helper methods and widgets to simplify the task for form input and validation.
  • AJAX-enabled widgets Integrated with jQuery, Yii comes with a set of AJAX-enabled widgets, such as auto-complete input field, treeview, data grid, which enables writing highly efficient and versatile user interface extremely simple.
  • Authentication and authorization Yii has built-in authentication support. It also supports authorization via hierarchical role-based access control (RBAC).
  • Skinning and theming Yii implements a skinning and theming mechanism that allows you to quickly switch the outlook of a Yii-power website.
  • Web services Yii supports automatic generation of complex WSDL service specifications 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 application code.
  • Error handling and logging Errors are handled and presented more nicely, and log messages can be categorized, filtered and routed to different destinations.
  • Security Yii is equipped with many security measures to help prevent your Web applications from attacks such as SQL injection, cross-site scripting (XSS), cross-site request forgery (CSRF), and cookie tampering.
  • Unit and functionality testing Yii provides support for writing and running unit tests as well as functionality tests, based on PHPUnit and Selenium.
  • Automatic code generation Yii provides a set of intuitive and highly extensible code generation tools that can help you quickly generate the code you need for features such as form input, CRUD.
  • Compliance to XHTML HTML code produced by Yii components and code generators complies to the XHTML standard.
  • Purely object-oriented Yii framework sticks to strict OOP paradigm. It does not define any global function or variable. And the class hierarchy that it defines allows maximum reusability and customization.
  • Friendly with third-party code Yii is carefully designed to work well with third-party code. For example, you can use code from PEAR or Zend Framework in your Yii application.
  • Detailed documentation Every single method or property is clearly documented. A book and comprehensive tutorials are also available for you to systematically learn Yii.
  • Extension library Yii provides an extension library consisting of user-contributed components. This makes the above feature list never ending.
You might initially try Yii for its speed, security, feature richness, and superb engineering. But you'll stick with it because it is just so intuitive, flexible and fun. Don't take our word for it. Dive in deeper and see for yourself: Take the tour. And when your ready to get your hands a little dirty, download the framework and follow the tutorials.

About Yii

Yii is a high-performance PHP framework best for developing Web 2.0 applications.
Yii helps Web developers build complex applications and deliver them on-time.
Yii is pronounced as Yee or [ji:], and is an acroynym for "Yes It Is!". This is often the accurate, and most concise response to inquires from those new to Yii:
Is it fast? ... Is it secure? ... Is it professional? ... Is it right for my next project? ... Yes, it is!
Yii is a free, open-source Web application development framework written in PHP5 that promotes clean, DRY design and encourages rapid development. It works to streamline your application development and helps to ensure an extremely efficient, extensible, and maintainable end product.
Being extremely performance optimized, Yii is a perfect choice for any sized project. However, it has been built with sophisticated, enterprise applications in mind. You have full control over the configuration from head-to-toe (presentation-to-persistence) to conform to your enterprise development guidelines. It comes packaged with tools to help test and debug your application, and has clear and comprehensive documentation.
To learn more about what Yii brings to the table, check out the features section.

History

Yii is the brainchild of its founder, Qiang Xue, who started the Yii project on January 1, 2008. Qiang previously developed and maintained the Prado framework. The years of experience gained and developer feedback gathered from that project solidified the need for an extremely fast, secure and professional framework that is tailor-made to meet the expectations of Web 2.0 application development. On December 3, 2008, after nearly one year's development, Yii 1.0 was formally released to the public.
Its extremely impressive performance metrics when compared to other PHP-based frameworks immediately drew very positive attention and its popularity and adoption continues to grow at an ever increasing rate.