Yii news 2021, issue 2
Published on May 7, 2021 by Alexander Makarov
Hello, community!
It is Alex Makarov, samdark, writing. This is a second issue this year. I was trying to get someone else from the team to write an intro for the issue but, it seems, they prefer to write code instead :)
We have some great updates regarding Yii 3 and many Yii 2 releases. Additionally, there are side efforts that might be interesting.
Status page
Since the question "How is Yii3 progress overall" is asked too often, we have put together a page tracking Yii3-related packages. The calculation is simple. A package with a stable version is considered "done". A package without a stable version is considered not "done". The framework does not require all the packages so expect beta before 100% is reached. A bit later a link to this summary page will be added to the main website page.
Design improvements
The creator of awesomic invited us to use the service for free to say thanks for Yii 2. We are not going to do a full re-design of the website since it will move our focus too much from the development of Yii3. Instead, the first goals are the following:
- Refresh the logo without losing its identity.
- Create a consistent style guide with logo, colors, shapes, fonts, etc.
- Create a consistent style guide for documentation diagrams and schemas.
- Get a great look for Yii 3 application templates and demo.
- Get a great look for Debugger and Gii.
Community
Historically, the Yii community was migrating from one platform to another. In Yii 1 time it was primarily the forum which is still the preferred place for asking tricky questions since it is indexed well by search engines. We have used IRC as a chat platform. Later communities gathered at Facebook and StackOverflow. IRC was not convenient for many, so we have tried Gitter and then Slack.
Nowadays for Yii3 we have a Telegram group and it seems it is gathering more attention than the Slack one.
🔷 Yii 2
A big set of updates is ready:
- Yii 2.0.42.
- Apidoc 2.1.6.
- Auth client 2.2.10.
- Bootstrap4 2.0.10.
- Debug 2.1.17.
- Redis 2.0.15.
- Queue 2.3.2.
- Gii 2.2.2.
- ElasticSearch 2.1.1.
🔶 Yii 3
Yii3 is moving forward a bit slower than I have hoped for. Nevertheless, I love the progress. We are releasing more and more stable independent packages and constantly shaping fundamentals such as configuration and container.
🎁 Package releases:
- Injector 1.0.4.
- Test support 1.2.1 and 1.3.0.
- HTML 1.0.0, 1.1.0, and 1.2.0.
- Var dumper 1.0.5 and 1.1.0.
- Profiler 1.0.0.
- Cookies 1.1.0 adding security features.
More packages are on the way.
Now, let's highlight interesting things since the previous issue. For convenience, changes will be grouped.
Application templates and demos
- Console is now accessed as ./yii, not as ./vendor/bin/yii. In existing projects, you need to add yii entry script.
- @layout was added to aliases.
- PHP 8 compatible Faker is now used in the demo.
- Demo's contact page files were grouped more.
Routing and middleware dispatching
- Middleware dispatcher got refactoring and renaming.
- There is now an ability to disable middleware in a route or sub-group. Useful if you need to make an exception for a certain route. For example, not to check CSRF token presence.
- The syntax overall was updated. You can see it in action in the demo.
- Static routes support was added.
Assets
The assets package is close to release with all the issues solved, documentation written and great test coverage achieved.
DI and Factory
There is a breaking change in the syntax. __class is now class, properties are prefixed with $. Also, namespaces were adjusted a bit. Likely that is the last change about DI container declarative syntax.
These changes allowed us to add metadata for definitions without the risk of having conflicts with properties:
- Added tags support. Useful if you want to feed an array of services to another service.
- Added the ability to reset state. Necessary for state-aware services when you run Yii3 in an event loop.
Configs
A new config plugin was a good idea. With the following improvements it became convenient to use:
- The package list is built with dependencies and depth in mind.
- Options moved to config-plugin-options.
- The ability for a package to specify configs base path. Results in fewer sub-directories.
- Better error messages.
- Interactive mode with the ability to display diff, update configs, etc.
- More default configs were added to packages overall.
More enhancements are to be done.
Data response
- Content negotiating middleware was added
- Some edge cases about when to format response were considered.
Translator
The set of translator packages are almost ready for release. Besides cleanup, we have added a translation extractor and a console command for it so now usability-wise it is at least as convenient as translations in Yii 2.
Console
Docker
Fixed Docker images, including ones with Nginx. These are now built automatically via GitHub actions and are available via Docker hub.
📙 New and adjusted docs
- Middleware - additional diagrams to explain the concept better.
- Cookies - signing and encrypting cookies.
📚 Reading recommendations
- Converting Yii2 to Yii3
- How to dump and inspect PHP OPCodes
- Function Inlining in Zend Engine
- Do not mock what you do not own
❤️ Thank you!
I would like to thank all backers and contributors for making Yii 3 possible. We are moving it forward together!
- CraftCMS - Great OpenSource Yii2-powered CMS.
- Onetwist Software - High-quality software development.
- SkillShare - Online learning community.
- Betteridge - Fine jewelry.
- dmstr - Docker-based cloud solutions.
- HumHub - OpenSource team communication solution.
- JetBrains - Awesome developer tools.
- Skin.Club - CS:GO skins market.
- EFKO Group - Foodtech, food production, and a venture foundation.
👍 Special thanks for Yii 3 code contributions goes to:
- Wilmer Arambula.
- Vitalii Shkolin.
- Leonid Chernenko.
- Rustam Mamadaminov.
- Aleksei Gagarin.
- Evgeniy Zyubin.
- Mister 42.
- Valerii Gorbachev.
- Sergei Predvoditelev.
- yiiliveext.
- Anton Samoylenko.
- Alexander Nekrasov.
- Roman Tsurkanu.
- Evgeniy Tkachenko.
- DizhovskyyD.
- Igor Maliy.
- WinterSilence.