Yii news 2020, issue 8
Hello, everyone! This is the last Yii news issue of crazy 2020. I have barely managed to put it together because of Yii 3 development speed increased a lot. We haven't tagged all package releases this month, but many packages are very close so expect more releases in January.
Happy New Year! Let it be a bit less crazy than 2020. - Alexander Makarov
// Don't forget to star packages you like at GitHub.
Foundation and team
- Evgeniy Zyubin joined the team full-time to work on Yii 3 and did great so far.
- Valerii Gorbachev joined the team as well. You likely know him for the work on i18n and MSSQL.
- All available funding is now spent giving more time to the team and resulting in a massive development speed boost.
The year proved that we can efficiently spend funds on development so contributing financially helps the project really well.
🔷 Yii 1
Yii 1.1.23 was released. It adds support for PHP 8 and improves compatibility for PHP 7. It also adds support for PostgreSQL 12.
That is the first release Marco van 't Wout tagged with the help of Carsten Brandt.
🔷 Yii 2
Yii 2.0.40 release was done. The release is mostly focused on fixing issues found since last release.
The following extensions were released as well:
Additionally:
- Oracle DB tests up and running via GitHub actions.
- Fresh Docker images are now built via GitHub actions.
- Codeception Yii 2 module is now compatible with PHP 8.
🔶 Yii 3
Infrastructure
- Applied new StyleCI rules to all repositories. Code style is even more consistent now.
- Overall tests coverage and mutation score were increased for nealy every package.
- Trimmed Git history of some packages that were sub-split from Yii 2 back then and were dragging all of its git history.
- Enabled GitHub discussions in yiisoft/app. Will see how it goes. It is not meant to replace forums but may serve us good.
Releases
- Cookies 1.0.0. The package will be likely first used in Flarum project.
- Strings 1.0.0. Additionally to overall cleanup there's StringHelper::split() now.
- Test support 1.0.0. Since last news issue it got docs and cache testing.
- Aliases 1.1.2
- Composer config plugin 0.5.0
- i18n 1.0.0
- Session 1.0.0. Since last news issue the session was optimized not to be opened when possible.
- HTTP 1.1.0. The release adds ContentDispositionHeader that helps to build cross-browser RFC-compliant header value.
New packages
Not only packages get added... some packages were removed such as yii-api.
Arrays
Files helper and file system
File helper got the following changes:
- Added FileHelper::isEmptyDirectory().
- Added FileHelper::openFile().
- Added FileHelper::lastModifiedTime() that is able to get last modification time for a directory contents.
- Added FileHelper::findDirectories() and FileHelper::findFiles().
- FileHelper::unlink() now handles more edge cases including Windows.
- FileHelper::filterPath() was replaced with separate PathMatcher.
File system package now uses stable version of Flysystem.
Console
public/index.php is now used as router by default in yii serve command. That was made to handle routes with dot in them with the build-in server.
DB and Active Record
Good progress was made to clean up Yii2-ported database package. It's far from being complete, but we're getting there. Interesting changes:
- Cache was split from Connection.
- Some Yii 2 MSSQL changes were ported.
- Active Record is now tested against Oracle.
Migrations
- Overall cleanup and docs update.
- Migration classes are now named in PascalCase.
Cycle DB
Error handler
Error pages got new design provided by Arkadiy Zimn and Fedor Dostoevsky.
You can switch to dark/light theme so night coding errors won't burn your eyes anymore.
Debugger
- Server parts of debugger got cleanup, collector improvements and fixes.
- It now requires way less manual configuration and could be turned on with a simple boolean flag in the config.
- Memory usage calculation was fixed.
- All the reading and writing is now done through proper abstraction.
Frontend part of debugger is still in the heavy development.
Profiler
- Overall cleanup and refactoring was performed.
- Default configuration was added.
Development tool
Development tool got some improvements:
- Refactoring was done.
- test command that silently does tests for a package and prints only if there are errors.
- git/pr/create command that is able to create GitHub pull requests.
- github/settings command that helps mass-changing settings of GitHub repositories.
- Error became more helpful.
- replicate/copy-file command that is able to copy any file to all the packages specified.
- It now plays nicely with symlinks in Docker containers.
- exec output is now realtime.
- release/make command got extra checks and workflows. That's what was used for recent package releases.
Translator
The package is almost ready for stable release.
Demo application
Demo application is kept up to date with recent framework changes.
- index.php now serves as yii serve router.
- Router cache is disabled by default.
- Logout is now performed as POST request.
- There's no need now to use CSRF explicitly in controllers.
- Menu items are now properly being activated.
- Overall classes are now grouped by use-case rather than by type.
- Switched to Bootstrap 5.
- Required fields are now visually marked as such.
- 404 fallback page was added.
- Flash message was extracted into widget.
- Configuration isn't rebuilt now in debug more unless config files were changed.
Web application template
- The template was cleaned up. All the unnecessary parts were removed.
- index.php now serves as yii serve router.
- Router cache is disabled by default.
- Overall classes are now grouped by use-case rather than by type.
- Added debugger API.
- Custom error page and required fields indicator.
- Configuration isn't rebuilt now in debug more unless config files were changed.
Also, there's new start page:
API application template
- Configuration was adjusted to match web application template.
- index.php now serves as yii serve router.
- Router cache is disabled by default.
- Swagger is added to the template with all the sample API available documented.
- Overall classes are now grouped by use-case rather than by type.
- REST routes group was added.
- Configuration isn't rebuilt now in debug more unless config files were changed.
The template currently contains some example parts that are better to be in the demo. Closer to release these will be moved.
Cache
Cache was significantly refactored. Yii's cache package became a non-PSR cache that uses PSR-16 handlers. It is able to set default TTL and prefix, provides cache stampede protection, and dependency invalidation.
Most handlers were cleaned up and refactored so expect release in the beginning of the next year.
Log
Log got major cleanup and refactoring as well. For end user it still is a PSR-compatible logger but configuration and feature-wise it became a lot better:
- Customizable log format.
- StreamTarget was added for writing to the output stream.
- Resource consumption was reduced.
- There's now ability to add your own context.
Var dumper
- Better edge case handling.
- More tests and refactoring.
- Exporting of closures was extracted into its own class, ClosureExporter.
Bootstrap
Various updates were made to both Bootstrap 4 and Bootstrap 5 packages.
- Markup updates.
- Ability to expand a certain item for Accordion and other widget enhancements.
- The package now provides a config for application form field classes so when installed, it styles forms automatically.
Bulma
- The package now provides a config for application form field classes so when installed, it styles forms automatically.
- Tabs widget was added.
- Progress bar widget was added.
- Modal widget was added.
Router
- Slightly improved error messages.
- Ability to override routes.
- Ability to enable/disable cache from application parameters.
Serializer
The package future is to be considered. While it proved to be useful for some cases, in simple cases it's an overkill and in complex cases it's often not enough.
HTML
- Cleanup, deprecations removed.
- Add Html::div(), Html::span() and Html::p().
Assets
Widgets
Public API was adjusted significantly to support immutability within widgets. Personally I think that syntax got better:
<?= MyWidget::widget()->options(['class' => 'testMe'])->begin() ?>
Content
<?= MyWidget::end() ?>
CSRF
CSRF got major refactoring. As a result:
- It is more logically structured.
- More secure.
- Got interfaces to implement your own protection algorithms.
- Got stateless token algorithm support out of the box.
- Got default configs.
First third party packages
While Yii 3 is not released yet, there are some third party packages appearing for it. One we'll highlight today is about inlining SVGs:
📙 New and adjusted docs
- Got more packages documented properly in their READMEs.
- Logging documentation was updated.
Overall documentation is now outdated. The concepts are the same but concrete syntax was adjusted in the code. It will be worked on next year.
📚 Reading recommendations and other news
❤️ Thank you!
I'd like to thank all backers and contributors making Yii 3 possible. We are moving it forward together.
👍 Special thanks for Yii 3 code contributions goes to:
- Wilmer Arambula.
- Rustam Mamadaminov.
- Viktor Babanov.
- Valerii Gorbachev.
- Evgeniy Zyubin.
- Roman Tsurkanu.
- Dmitry Derepko.
- Sergei Predvoditelev.
- Anton Samoylenko.
- mj4444.
- yiiliveext.
- Martín Peveri.
- Vitalii Shkolin.
- Leonid Chenenko.
- Mister 42.
- Sergei Iamskoi.
- Alexey Chernousov.
- epifrin.
- Aleksei Gagarin.
- Insolita.
- Pavel Ivanov.
- 1Luc1.
- Rei Bengu.
- Roman Hlushchak.