Yii2: performance optimization and refactoring

Illustration of optimizing the performance of a web application on the Yii2 framework with server, caching, database and application architecture elements

Содержание

Навигация

General provisions

The vast majority of web applications in the world (about 72%) use PHP as their server-side programming language1. The widespread use of PHP in the field of web application development is largely due to the features of this programming language, among which we can specifically mention: dynamic typing; high speed of web applications; good backward compatibility; active developer community; a large number of open source components and libraries.

In addition, PHP is actively developing. Initially (in 1994), PHP was a simple set of CGI scripts written in the C programming language. Starting with the third version (1998), PHP began to support object-oriented syntax2. The seventh version of PHP (2015) provided a significant increase in performance (application execution speed increased by approximately 2 times compared to PHP 5.6). At the moment, the latest stable version of PHP is 8.5.33, which includes all the language constructs necessary for application development.

The popularity of PHP is also explained by the fact that the WordPress content management system (the first release of which took place in 2003) was developed in this programming language4. Currently, WordPress is the most widely used content management system in the world5 (the number of sites developed on the basis of this platform has exceeded 36 million).

Despite the significant adoption of the WordPress content management system, developers needed more flexibility in developing web applications. This led to the fact that, starting around 2005, developers increasingly began to develop their applications using frameworks. In 2005, the PHP frameworks Symfony6 and CakePHP7 were released. In 2006 - CodeIgniter8, in 2008 the first version of the Yii9 framework was released. In 2011, the Laravel10 framework was developed. The stable release of the Yii2 framework was released in 201411.

In 2016, the first stable release of the Composer dependency manager took place12 (the development of which began in 201113). The presence of a universal dependency manager for PHP with automatic installation and updating of libraries, integration with the official repository of PHP packages Packagist14 made it possible to most effectively use the component approach when developing applications in PHP. For these reasons, Composer's dependency manager has become an industry standard and has been integrated into all popular PHP frameworks, including Yii2.

The website trends.builtwith.com presents trends in the use of web technologies. According to the data presented on this site, the most widely used PHP framework in the world is Laravel. The total number of web applications developed using the Laravel framework in the world is 709,236, in Russia - 16,24415. However, in Russia the most common framework is Yii. The total number of web applications developed using the Yii framework in the world is 93,709, in Russia - 26,14516.

The peculiarity of Yii2 is that this framework provides the software engineer with ease and high speed of development, debugging, profiling, and also includes built-in tools for optimizing application performance. Yii2 today allows you to develop web applications of any complexity. The above circumstances determine the popularity of this framework.

Quite a lot of applications have been developed based on Yii2 that need to be supported and new functionality added. This leads to the complexity of such projects. At the same time, you should also ensure high speed of applications. For this reason, there is inevitably a need to optimize the performance of such applications. The corresponding task becomes more complicated as application traffic increases and the size of databases increases. The above circumstances are often a consequence of the increase in popularity of the application.

At the end of December 2025, the third version of the Yii framework was released 17, but the developers of the third version did not provide backward compatibility with the previous version of the framework. In other words, the third version of Yii is a new framework. It is not possible to switch from the second version to the third. Software developers who decide to migrate from the second version of the Yii framework to the third will have to develop the application from scratch and abandon a significant part of the previously written code.

It is currently too early to draw conclusions as to whether the third version of the framework will be as popular as the second and whether developers will create new and rewrite existing applications using the new (third) version of the Yii framework. For this reason, both currently and in the medium term, the task of optimizing the performance of applications developed using the second version of the Yii framework seems to be the most relevant.

It is also important to note that optimizing the performance of a web application is a complex task. To achieve the best results in improving application performance, you must: use the built-in capabilities of the programming language and framework; configure the infrastructure in the most productive way; optimize the database; and also apply ways to optimize the client part of the application (frontend). Currently, this information is scattered and found in different sources. For this reason, there is a need to systematize ways to optimize the performance of web applications developed using the Yii2 framework.

This work is a comprehensive study of ways to optimize the performance of web applications developed in PHP using the Yii2 framework. In this work, we are guided by a systematic and broad approach to optimizing the performance of web applications; we are not limited solely to optimization at the framework level, but also include optimization at the levels of the server infrastructure, the client part of the application (frontend) and the database. It is this approach to performance optimization that is most in demand today both in scientific research (taking into account the lack of such research) and in the practical activities of specialists in the field of software engineering.


  1.   W3Techs. Statistics on the use of programming languages. [Electronic resource]. – URL: https://w3techs.com/technologies/overview/programming_language (access date: 02/16/2026). 

  2.   History of PHP and related projects. [Electronic resource]. – URL: PHP https://www.php.net/manual/ru/history.php (access date: 02/16/2026). 

  3.   PHP 2026 news archive. [Electronic resource]. – URL: https://www.php.net/releases/index.php (access date: 02/16/2026). 

  4.   The history of WordPress. [Electronic resource]. – URL: https://wordpress.org/about/history/ (date of access: 02/16/2026). 

  5.   W3Techs. Reviews of world web technologies. [Electronic resource]. – URL: https://w3techs.com/ (access date: 02/16/2026). 

  6.   The definitive Guide to Symfony. [Electronic resource]. – URL: https://symfony.com/legacy/doc/book/1_0/en/01-Introducing-Symfony (access date: 02/16/2026). 

  7.   Introduction to CakePHP. [Electronic resource]. – URL: https://legacybook.cakephp.org/1.1/en/introduction-to-cakephp.html (access date: 02/16/2026). 

  8.   CodeIgniter User Guide. [Electronic resource]. – URL: https://codeigniter.com/userguide2/changelog.html (access date: 02/16/2026). 

  9.   The official forum of the Yii framework. [Electronic resource]. – URL: https://forum.yiiframework.com/t/yii-1-0-0-is-released/13877 (access date: 02/16/2026). 

  10.   Laravel Versions. [Electronic resource]. – URL: https://laravelversions.com/en (date of access: 02/16/2026). 

  11.   The official GitHub repository of the Yii framework. [Electronic resource]. – URL: https://github.com/yiisoft/yii2/releases/tag/2.0.0 (access date: 02/16/2026). 

  12.   The official GitHub repository of the dependency manager for PHP Composer. [Electronic resource]. – URL: https://github.com/composer/composer/releases/tag/1.0.0 (access date: 02/16/2026). 

  13.   The official GitHub repository of the dependency manager for PHP Composer. [Electronic resource]. – URL: https://github.com/composer/composer (access date: 02/16/2026). 

  14.   Packagist's official PHP package repository. [Electronic resource]. – URL: https://packagist.org/ (date of access: 02/16/2026). 

  15.   Statistics on the use of the Laravel framework. [Electronic resource]. – URL: https://trends.builtwith.com/ru/framework/Laravel (access date: 02/16/2026). 

  16.   Statistics of using the Yii framework. [Electronic resource]. – URL: https://trends.builtwith.com/ru/cms/Yii-Framework (access date: 02/16/2026). 

  17.   Yii framework news. [Electronic resource]. – URL: https://www.yiiframework.com/news/777/yii3-is-released (access date: 02/16/2026).