Following best practices
In this recipe, you will see how to configure Yii2 for the best performance and some additional principles of building responsive applications. These principles are both general and Yii-related. Therefore, we will be able to apply some of these even without using Yii2.
Getting ready
Create a new yii2-app-basic
application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guidestart-installation.html.
How to do it…
Update your PHP to the latest stable version. Major releases of PHP may bring significant performance improvements. Turn off the debug mode and set the
prod
environment. This can be done by editingweb/index.php
as follows:defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_ENV') or define('YII_ENV', 'prod');
Note
Note: In the
yii2-app-advanced
application skeleton, you can use the shell commandphp init
and opt production environment for loading optimizedindex.php
and configuration files...