James Galley

Web application developer

PHP, Yii, MySQL, Node.js - JavaScript, HTML, CSS & SASS - Linux, AWS & serverless

Upgrading Yii 1 web applications to Yii 2

Yii is a PHP framework ideal for building web applications, APIs and complex dynamic websites.

Currently in version 2, Yii's previous major version 1 is now in maintenance mode, and will soon be end-of-life. Migrating from Yii1 to Yii2 will become important for any owners of Yii1 websites.

What's the difference between Yii 1 and Yii 2?

Yii 1 was released in 2008 and quickly established itself as a powerful MVC framework and a viable alternative to other PHP frameworks like CodeIgniter and later, Laravel. Version 1 of Yii had drawbacks though, such as poor environment config support, and the framework often needed a bit of wrapper code to get it to do what you wanted.

Yii 2 was released in 2014 as a completely re-written PHP framework which brought the framework up-to-date with new versions of PHP and resolved almost all of the previous version's shortcomings. Yii 2 makes better use of Composer to manage its own framework code, and 3rd-party packages, and introduces a raft of other improvements to application architecture, configuration and command line support. Migrating from Yii 1 to Yii 2 can therefore bring these benefits to your website or web application.

The developers of Yii announced in 2015 that Yii 1 would be deprecated, and currently Yii 1 is in maintenance mode only, with only security and PHP version fixes being made - and will no longer be supported by the developers from December 31st, 2020.

Image of Yii 1 codebase, showing getVersion() function

What can I do if I have a Yii 1 web application?

Many applications and websites built with Yii 1 still exist and will continue to function, even past the obsolecense date of the framework. However business owners who use Yii 1 to power their PHP web applications or website may want to consider upgrading to Yii 2 in advance of the cut-off date in order to be certain of security standards and system availability.

Upgrading from Yii 1 to Yii 2 can be a complex task, as the framework is not backwards compatible - Yii 2 was designed from the ground up in a very different way. However upgrading from Yii 1 is perfectly possible and can often be a good opportunity to redesign and improve aspects of your software.

I have upgraded several websites and web applications to Yii 2 over the last few years and seen benefits to security, speed and maintainability of the software concerned.

For developers, the Yii website offers very good documentation on upgrading from Yii 1 to Yii 2.