20.11.2014 Views

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

etrieve the cookie with the specified name<br />

$cookie=<strong>Yii</strong>::app()->request->cookies[$name];<br />

$value=$cookie->value;<br />

......<br />

// send a cookie<br />

$cookie=new CHttpCookie($name,$value);<br />

<strong>Yii</strong>::app()->request->cookies[$name]=$cookie;<br />

Ajustes no Desempenho<br />

Performance of Web applications is affected by many factors. Database access, file<br />

system operations, network bandwidth are all potential affecting factors. <strong>Yii</strong> has tried in<br />

every aspect to reduce the performance impact caused by the framework. But still, there<br />

are many places in the user application that can be improved to boost performance.<br />

Enabling APC Extension<br />

Enabling the PHP APC extension is perhaps the easiest way to improve the overall<br />

performance of an application. The extension caches and optimizes PHP intermediate<br />

code and avoids the time spent in parsing PHP scripts for every incoming request.<br />

Disabling Debug Mode<br />

Disabling debug mode is another easy way to improve performance. A <strong>Yii</strong> application runs<br />

in debug mode if the constant YII_DEBUG is defined as true. Debug mode is useful during<br />

development stage, but it would impact performance because some components cause<br />

extra burden in debug mode. For example, the message logger may record additional<br />

debug information for every message being logged.<br />

Using yiilite.php<br />

When the PHP APC extension is enabled, we can replace yii.php with a different <strong>Yii</strong><br />

bootstrap file named yiilite.php to further boost the performance of a <strong>Yii</strong>-powered<br />

application.<br />

The file yiilite.php comes with every <strong>Yii</strong> release. It is the result of merging some commonly<br />

used <strong>Yii</strong> class files. Both comments and trace statements are stripped from the merged<br />

file. Therefore, using yiilite.php would reduce the number of files being included and avoid<br />

execution of trace statements.<br />

Note, using yiilite.php without APC may actually reduce performance, because yiilite.php<br />

contains some classes that are not necessarily used in every request and would take extra<br />

parsing time. It is also observed that using yiilite.php is slower with some server<br />

configurations, even when APC is turned on. The best way to judge whether to use<br />

yiilite.php or not is to run a benchmark using the included hello world demo.<br />

Using Caching Techniques

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!