DEV Community

david duymelinck
david duymelinck

Posted on

My 2 cents on Yii3

I got to exploring Yii3 via Craft CMS. Craft is moving to Laravel with their sixth version. When I saw the announcement I was thinking Yii was having problems because Yii3 was stuck for a long time on 80 precent, if I can remember that right.
But now I have seen Yii3 I think the decision is more because they needed change their guts anyway when they update to Yii3.

Major changes

Yii2 is, like most other frameworks, one pre-configured bundle. With Yii3 all components are separate and the glue that binds them together are the templates; web, api, console. The workhorse of the templates is the configuration.

This loose structure allows the framework to use different setups depending on the need of the application.
There are multiple runners to pick your flavour of PHP runtime.
You can use the database package you prefer.

The use of Yii::$app-> is discouraged.

Routes can now be any callable you want, which brings Yii3 to the same level as the other frameworks.

No frontend related packages as Composer dependencies. This was the biggest problem for me to use the previous version. A backend framework should be frontend agnostic.

Where they can improve

The configuration is very confusing at first sight.
The main configuration file has variables in it as strings.
The dependency injection configuration looks more like a Wordpress configuration than a modern framework configuration.
While I get it that using arrays is the most versatile way to allow all the configuration options, most frameworks have started to use attributes for a better developer experience.

It is still using nikic/FastRoute. While it was a good router library, others implemented the same technique and got faster after further development.

Conclusion

I do think with Yii3 they moved the framework in the right direction. The closest framework in spirit to Yii3 that comes to mind is Laminas.

The question is will it be enough to survive when the most known solution build on it is moving away?
The numbers on their website are mainly from the use of the previous versions of the framework. A big change will always scare people away.

Top comments (0)