TL; DR: Yii is an open-source, component-based PHP framework for developing modern web apps and deploying them using your choice of hosting options. Launched in 2008, it was one of the earliest Model-View-Controller (MVC) frameworks and is backed by a strong core developer team and large contributor community. Keep an eye out for the upcoming release of Yii Version 3.0, which will present a refreshing departure from the status quo.
In Chinese, the word Yii (pronounced Yee) is used to describe something simple and evolutionary. It makes sense, then, why Founder Qiang Xue chose the moniker for his generic PHP framework — which he designed according to his philosophy that code should be written in a simple yet elegant way.
“In 2008, when Yii 1.0 was released, there were not many PHP web application frameworks that were well-designed, well-maintained, high performing, easy-to-use, and very customizable,” said Alexander Makarov, Core Developer at Yii. “By default, we try to make things simpler, not more complicated. That’s why Qiang Xue spent lots of time investing in it: to make it easier to debug code.”
Every method in Version 1.0, 1.1, and 2.0 of the framework is properly documented. That is why generated API documentation is complete — something that no other framework, including Symfony, Zend Framework, and Laravel, has achieved.
As a generic framework, developers can use Yii to rapidly develop all types of web applications using PHP but its component-based architecture and advanced caching support make it particularly suitable for large-scale projects. Use cases include portals, forums, content management systems, ecommerce projects, and RESTful web services that can be deployed using multiple hosting environments.
Yii is exceptionally extensible, allowing for the addition of new functionalities and capabilities as needed. Developers can replace or customize nearly every piece of code while taking advantage of the framework’s architecture to employ or create redistributable extensions.
Pioneering the MVC Framework Space
Founder Qiang Xue served as product lead for Yii from December 2008 to June 2015, when he stepped away from the project.
“We were one of the first Model-View-Controller (MVC) frameworks out there,” Alexander said. “Qiang Xue built the initial framework, gathered a great team, and led the community until 2015. I joined around 2010. I am the coauthor of Yii Version 2.0, currently leading the Yii Version 3.0 effort.”
But Yii is far from a one-man show. Today, Alexander leads the core development team, which keeps track of trends in other frameworks that are then used to inform and create new features. The project is also backed by an open-source community of professionals who consistently contribute to Yii’s evolution.
In addition to contributing code, translating documentation, and participating in community activities, the open-source community also donates financial resources to keep the project sustainable. The money is primarily used to ensure core team members can work on Yii without seeking additional employment.
Members can contribute a one-time donation or recurring monthly contributions. The funds also support server infrastructure, development tools, design services, and marketing efforts.
Rapidly Develop and Deploy Modern Web Applications
Getting started with Yii, a framework based on object-oriented programming (OOP), requires a little background knowledge in OOP-based frameworks. Those who use Yii 2.0 should have an understanding of modern PHP features, including namespaces and traits (Yii 2.0 runs best on the latest version of PHP 7, but requires PHP 5.4.0 or above).
Alexander told us developers can run Yii on pretty much any infrastructure, whether you’re working with shared hosting or a VM, though small adjustments may be needed.
“Both Yii Version 1.1 and Version 2.0 run well pretty much anywhere, though simple adjustments may be required,” he said. “Google Cloud web hosting, for example, doesn’t have a traditional file system — and we are writing to the runtime directory by default, so it requires some customization.”
Yii features two application templates: a Basic Project Template, suitable for 90% of development needs, and an Advanced Project Template. Alexander said it’s important to take hosting into consideration when choosing a template.
“The advanced template was created for multitiered projects with a frontend, backend API, etc. — different entry points,” he said. “Many hosting providers do not support that; they support a single web root, and an advanced application template requires at least two web roots.”
If a developer starts with the advanced template and then attempts to deploy the app on a virtual private server, for instance, it would be necessary to switch templates. “ It requires some development time, but it’s not impossible,” Alexander said.
Yii Version 3.0: An Upcoming Departure From the Status Quo
Since Yii 1.0 was released in 2008, the team supporting the framework has navigated several challenges — one being unusually long support periods.
“We are still supporting Version 1.1 — recently, I added support for PHP 8,” Alexander said. “The range of PHP versions supported is incredible.”
Users also benefit from the ability to provide feedback through GitHub, forums, and even conferences. “We took feedback into account when deciding to support older versions of PHP because we learned from the community that there were extensive projects that would be very difficult to migrate,” he said.
In terms of future development, Yii is also turning to the user community for direction on Yii 3.0, which is still very much in the making. This latest edition will be quite different from its predecessors.
“It’s in the works and constantly changing, so we don’t recommend you use it right now, but it’s interesting to look into at this point,” Alexander said.
While Yii 1.0 and Yii 2.0 are quite similar in terms of infrastructure and extensions, Yii 3.0 is compatible with any composer package and does not require wrappers.
“Just a little bit of configuration, and that’s it — it’s way more accessible for the PHP community overall.”