Yii news 2021, issue 3
Published on August 20, 2021 by Alexander Makarov
Hello, community!
Alex here again. Yii team was silent for a while. Not because of nothing happens but the opposite. Too much happens and all that at the same time. It is pleasant to work on Yii3 since it is finally getting more stable and more complete.
Foundation
We have participated in FundOSS donation amplification pilot project. In total, 49 donors participated raising $813 that was amplified to $3295 (minus Stripe fees). That is a very significant aid to the project that will allow us to spend more time on framework development. Thanks to FundOSS, OpenCollective and, of course, our backers. I really hope to participate in alike project again.
Community
Also, there is now an experimental #yii3chronicles Telegram channel posting Yii development updates. For now, it is in Russian only, but it is possible that there will be alike channel in English in the future.
Design and website
Last time I have posted about awesomic invited us to use the service for free to say thanks for Yii 2. Since then, some cool work was done. At "official logos and design" page you can now find various kinds of new logo, favicons set, general guidelines, and a guide to diagrams.
Also, I have added "Looking for Yii 3 progress?" link to main website front page. Hope that would bring additional interest and more issues and PRs.
🔷 Yii 1
🔷 Yii 2
A big set of updates is ready:
- Yii 2.0.43.
- Auth client 2.2.11.
- Bootstrap 2.0.11.
- Debug 2.1.18.
- ElasticSearch 2.1.2.
- Gii 2.2.3.
- HTTP Client 2.0.14.
- MongoDB 2.1.12.
- Smarty 2.0.10.
- Templates were updated to use Bootstrap 4.
- Bootstrap 5.
- Docker images were updated to use XDebug 3.
There are significant PHP 8 compatibility issues identified in API documentation generator. We are on fixing it. Meanwhile, use PHP 7 for docs generation.
🔶 Yii 3
🎁 Package releases:
- Yii event.
- Error handler.
- Assets.
- Rate limiter.
- Data response.
- View.
- Yii view.
- View Twig renderer.
- Mailer and its SwiftMailer driver.
- Email log target.
- Cookies 1.2.0.
- Translator 1.0.0 and related packages.
- Rate limiter 2.0.0.
- Mutex and adapters 1.0.0.
I have decided not to include patch releases in the list and not to post these at the website for now. Takes too much time and mostly these are of no big interest.
We have deprecated a few packages as well:
- yiisoft/serializer.
- yiisoft/container-proxy.
- yiisoft/yii-debug-frontend (see below in Debugger section).
Currently, team main focus are yiisoft/factory and yiisoft/di. These are blocking 11 and 31 package releases correspondingly.
Infrastructure
We decided to run all package tests overnight additionally to doing it on commits. That would allow us to see if change in one package breaks another package. It is a rare situation for stable packages, but it is better to be sure than sorry. It is not applied to all repositories yet but will be soon.
Yii Config package now requires Composer 2. The reason is that Composer 1 does not see new packages at packagist so Yii 3 cannot be installed.
Yii development tool
- list command was added listing active packages.
- Symlinks aren't created anymore for disabled packages.
- Packages are now processed in alphabetic order.
- Any vendor package could now be added, not only yiisoft.
Application templates and demos
We have renamed "yii-demo" to just "demo" for consistency. Right now, the set of applications and demos is the following:
- yiisoft/demo - Classical server-generated HTML demo.
- yiisoft/demo-api - REST API demo.
- yiisoft/app - Classical server-generated HTML application template.
- yiisoft/app-api - REST API application template.
Minimal PHP version for all these was raised to PHP 8.0. Packages are still 7.4+ since these could be used separately.
Ability to add bootstrapping code was added. The config for it stays in config/bootstrap.php, config/bootstrap-web.php, config/bootstrap-console.php and is empty by default. You can add callables such as function (ContainerInterface $container): void. These will be called at application startup.
composer run serve command could be used as an alias of ./yii serve now.
Overall directories structure got a bit simpler, and we work on making it even more simple.
DI container and factory
Both DI container and factory are now blocking further releases so these are our main focus now and are under heavy refactoring and development:
- They are becoming stricter with more validation in development mode and mostly one way to set definitions.
- Error messages improved significantly providing more information.
- Code coverage improved a lot.
Container:
- Context container was removed along with delegate lookup since it was duplicating composite container functionality.
- Service providers were introduced instead of previous providers (DeferredServiceProvider and ServiceProvider). These are inspired by container-interop but are not the same since we have identified a few issues in that standard draft.
- Internal definition storage format was adjusted for way more convenient debugging.
- ReferencesArray and DynamicReferencesArray were added. It allowed to simplify configs a bit.
Factory:
- Factory::create() now accepts a single argument. A definition of the class to create.
- Factory does not implement PSR ContainerInterface anymore. Factory::get() and Factory::has() were removed.
- Circular references detection was added.
Queue
- Configuration was simplified for simple cases. It is enough to configure AMQP broker and the rest would work out of the box.
- It is more convenient to configure channels now.
- AMQP adapter does basic ack for processed messages.
HTML
Middleware dispatcher
The package is close to be tagged. We still check alternative ideas about its design but current one is almost perfect.
- There are now proper docs in the package readme.
- It became way more resource-saving. Middleware instantiation is now lazy. Additionally, middleware instances are memory-cached, so it's performing better in event-loop environments such as RoadRunner and Swoole.
Validator
Validation rule syntax was adjusted:
// before (new Number())->integer()->min(44); // after Number::rule()->integer()->min(44);
Yii Sentry
Sentry integration package was created. Sentry is a log aggregation service that allows to efficiently monitor application code issues in production environments. Both web and console are supported.
Widgets
- Friendly exceptions are now used.
- Documentation was updated for both widget package and Yii widgets.
- All Yii widgets are now immutable.
- Got more tests and overall quality improvements.
- Bulma widgets package got big cleanup.
Error handling
- Friendly exceptions are now rendered in a more attractive way.
- We have decided to support markdown and declare it in the interface package.
- Exceptions in console applications are now properly logged.
Config
- Environments support was added.
- Improved config tracking when packages are added or removed. Hashes are stored in a dist.lock file.
Overall documentation was updated and expanded.
Debugger
- yiisoft/yii-debug is collecting debug info from your application.
- yiisoft/yii-debug-api is a REST API that provides debug info collected.
- yiisoft/yii-debug-viewer is a new client that could be both used as a module in an existing application or launched as a separate application. Adding your own panels is much easier than it was in the Angular version and is comparable to Yii2.
Viewer was added to application templates and demos and is accessible at http://127.0.0.1:8080/debug/viewer where 127.0.0.1:8080 is your local development host and port.
Router
Both internal refactorings and external API changes were made.
- When configuring a route in the application, IDE won't auto-complete non-configuration methods.
- Way less internals are exposed now to end user.
- Current route is now available through separate Yiisoft\Router\CurrentRoute service.
- Added ability to specify host for a group via Group::host().
- Added ability to specify route name prefix for the whole group Group::namePrefix().
📙 New and adjusted docs
📚 Reading/watching recommendations
- Introduction to the MVC programming paradigm through Yii2.
- Real World Benchmark PHP Routing.
- More Real World PHP Routing Benchmarks.
- Benchmark PHP Routing with Yii 2 results. We use FastRoute in Yii3.
- A demo of Temporal + Yii3.
- C4, Diagrams as Code & Architectural Joy.
- Tactician got Yii support.
- NoColor — validate the architecture of your PHP project.
- Composer sunsetting the PHP Version Stats Blog Series and Yii2 stats.
- Don't test constructors.
- PHP-FPM tuning: Using "pm static" for max performance.
- Microservice Architecture.
- Xdebug 3 videos.
- samdark reviewing Yii issues.
❤️ 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:
- Evgeniy Zyubin.
- Sergei Predvoditelev.
- yiiliveext.
- Wilmer Arambula.
- Rustam Mamadaminov.
- Dmitry Derepko.
- Mehdi Achour
- Valerii Gorbachev.
- Viktor Babanov.
- Anton Samoylenko.
- Toir Tuychiev.
- Alexander Nekrasov.
- Tarek K. Ajaj.
- Leonid Chernenko.
- Maksym Storchak.
- Aleksei Gagarin.
- Alexey Kopytko.
- Andrii Vasyliev.
- Razon Yang.
- Somogyi Márton.
- mj4444.
- Dmitry Egorov.
- Mister 42.
- ditibal.
- Igbanam Ogbuluijah.
- Julian Schmidt.
- kafkiansky.
- Alexey Chernousov.
- Carsten Brandt.
- Roman Tsurkanu.
- Marko Kaznovac.
- Andrey Skugarev.
- Tobias Munk.
🚀 1