Yii news 2021, issue 1
This is the first issue of Yii news in 2021. First months of the year were productive and resulted in Yii 3 package releases and significant progress in yet unreleased packages. We have improved our toolset, solved more issues and removed some packages. All that while trying to fix the problem with funding and taking care of Yii 2.
Foundation and team
Despite 2020 was way too crazy, it was alright for Yii. We have got agreements on extension of Yii 1.1 EOL in exchange of filling up the foundation and some more one-time alike agreements.
That, along with our beloved long-term supporters, allowed us to increase development speed by buying out more time of core team members. We did really well leveraging all the funds available.
I was excited about speedy development process way too much not taking a closer look at financial part and, in January I was surprised in a bad way. I totally forgot about non-recurring nature of big part of foundation income and the budget available was not enough. Not to make it too bad I, personally, have temporarily stopped invoicing the OpenCollective foundation (helped for it not to be a total disaster) and started to actively look for ways to partner with both Yii and PHP companies. Got mixed results so far but I hope that it will improve.
In case you want to talk about possible partnership, please do not hesitate to contact me at [email protected].
🔷 Yii 2
Yii 2.0.41 was released with the great effort of Paweł Brzozowski and invaluable Robert Korulczyk code reviews. Many hours were, as well, spent on security side of the framework. As a result, majority of current security reports were checked and release got security hardening.
🔶 Yii 3
🎁 First of all, package releases:
- Event dispatcher 1.0.0
- Test support 1.1.0 and 1.2.0
- CSRF 1.0.0
- Auth 2.0.0
- JWT auth 1.0.0
- Strings 1.2.0 and 2.0.0
- Arrays 1.0.0
- Cache and its drivers 1.0.0
- Request body parser 1.0.0
- Files 1.0.0
- Var dumper 1.0.0
- Log and its drivers 1.0.0
Each release means that documentation was written for a package readme, more tests were added, overall cleanup was performed and, of course, public API was stabilized enough.
Now, let's highlight interesting things since previous issue. For convenience changes will be grouped.
- ArrayHelper::pathExists() added.
- ArrayHelper::group() added (it is an alias of ArrayHelper::index()).
- Modifiers were removed.
Data abstraction got the following changes:
- DeletableInterface was added.
- PaginatorInterface and implementations got getSort() method.
- Sort itself can now be instantiated via static constructors for different modes.
- IdentityRepositoryInterface::findIdentityByToken() was extracted into IdentityWithTokenRepositoryInterface. Also, token is now configurable.
- JWT auth package was refactored.
After more effort to improve Composer config plugin was made, it became obvious that it is getting too complicated with AST, configs merging and everything that happens under the hood. Therefore, we have made it dependent on less yiisoft packages and, instead, developed a way simpler and performant alternative version.
All the application templates were switched to use it and there are likely bugs to be fixed and enhancements to be made.
Error handler got some improvements:
- General refactoring and readme.
- Xdebug 3 support for getting enhanced stacktraces.
- ExceptionResponder that is able form a custom response based on the error caught. That might be useful for handling exceptions such as NotFoundException etc. Whether such exceptions should be part of the framework is still under discussion.
- Renderers got an ability to send headers, header error renderer was added. It is useful for the cases when you cannot display errors right away such as some APIs, image generation etc.
- Call stack items that come from vendor are now grouped together and collapsed by default. Since errors are usually to be fixed in the application itself it makes the error page way less distractive.
Errors in general
- yiisoft/yii-event package got a debug mode which makes it check all the listeners defined in the config at once and reporting errors right away.
- DI container errors were improved to give more context.
- NumericHelper::isInteger() was added.
- NumericHelper::normalize() got support for booleans.
- Wildcard matching was re-thought replacing many configuration options with a ** that matches anything including separators.
- Proper PHP 8 support for edge cases.
- VarDumper::dump() now highlights code by default.
- VarDumper::asPhpString() was removed.
- Yii debugger-specific code was moved to debugger package.
- Closure export edge cases were fixed.
- d() and dd() function are now automatically available when the package is installed.
The package was significantly re-imagined. Two important changes are:
- Output is escaped by default.
- Tags are now separate objects created via Html static methods. For end user that means configuration is now done through methods that are auto-completed and verified in IDEs.
Lots of refactoring. Most notable changes are:
- Interfaces were extracted from Rule.
- Validator is now stateless.
- Nested validation rules are now supported.
- Message translation abstraction improved
- Ability for validated object to provide validation rules.
- Validator is now able to validate any data structure without it implementing DataSetInterface.
- InRange rule was divided into InRange and Subset.
- "required" attribute is now added to generated HTML based on validation rules.
- Due to validator changes, the way form is validated was changed.
Significant amount of effort was put into the packages so now it is almost read for being released. You can check the docs in the package readme.
DB and ActiveRecord
Both packages got some bugfixes and even more tests. Wilmer, who did most of migration job, already battle-tested it with a telegram bot having 120 thousand requests per day.
Both packages were originally ported from Yii 2 almost as is. Magic removed, types added, tests coverage went close to 100%. Despite getting better than they were in Yii 2, these packages are still close to Yii 2 design-wise and it is a hard decision whenever we should release first version in this state or do a huge refactoring first.
Likely it will be the former.
User package got refactoring and rethinking:
We are still not entirely satisfied with the results so likely more changes will follow.
Bootstrap and Bulma
- Bootstrap 4 package was deprecated and archived.
- Toast widget was added to Bootstrap.
- Panel widget was added to Bulma
- All configuration methods are now immutable.
- Both packages were adapted to changes in HTML package.
Console got an ability to add a command using custom name.
Progress was made both on the frontend and API parts.
- Data collection became more reliable.
- Route matching time is now collected. Container proxy was used to implement it without touching router.
- Console command to clear debug data was added.
- Frontend got sorting for requests list.
Yii development tool
The tool was improved for working with part of the packages installed. Accuracy of dependency fixer was greatly improved, and a new command was added, release/what. It suggests what package to work on next. Priority is given to packages without unstable dependencies that are blocking most other package releases.
- View injection was used for web templates.
- Layout was merged into a single file.
- Decided that an index page route will be always named "home".
- New yiisoft/config was applied.
- Application runner concept was applied.
- Event checker was added.
- Demonstrational parts from app-api were moved to new demo-api.
- Forms are not created via DI anymore.
📙 New and adjusted docs
- DI container readme
- 010 - Code Style
- 017 - Tags
- 018 - Widgets
- 019 - View code style
- Configuring SSL peer validation
- Handling errors
📚 Reading recommendations, packages and other news
- Building E-commerce website with Yii2.
- RoadRunner 2 is out.
- YiiPowered reached 647 projects.
- A draft of interactive shell for Yii 3.
- A package that turns emails and URLs in text and converts them to links.
- Does it belong in the application or domain layer?.
- Object properties and immutability.
- Contract tests.
❤️ Thank you!
I'd like to thank all backers and contributors making Yii 3 possible. We are moving it forward together.
I have realized that we have never emphasized on what companies are sponsoring Yii development so here is the top sponsors list with brief descriptions.
- 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.
There are individuals and other companies to be checked at OpenCollective page.
👍 Special thanks for Yii 3 code contributions goes to:
- Wilmer Arambula.
- Rustam Mamadaminov.
- Viktor Babanov.
- Valerii Gorbachev.
- Evgeniy Zyubin.
- Roman Tsurkanu.
- Aleksei Gagarin.
- Dmitry Derepko.
- Alexander Nekrasov.
- Sergei Predvoditelev.
- Michael Härtl.
- Vitalii Shkolin.
- Leonid Chenenko.
- Anton Samoylenko.
- Mister 42.
- Evgeniy Tkachenko.
- Julian Schmidt.
- Artur Avdonin.
- Arman Poghosyan.
- Dmitry Naumenko.
- Andrii Dembitskyi.
- Alexey Gevondyan.
- Milen Hristov.
- Marko Kaznovac.