YAML, Widgets and Lazy Arguments
- Feel free to use YAML for describing services, the syntax has been extended for this.
- Every service can now be registered as a Widget
- Mark arguments as very lazy to solve bottlenecks
About Lazy arguments
No matter if a Widget is used or not, WordPress will load all of them, every time, every class with every dependency.
This totally costs to much time and memory for each request so we needed a solution for that:
services:
SomeRepository: ~
MyWidget:
lazy_arguments: true
widgets: ~
arguments:
- '@SomeRepository'
The lazy_arguments
flag does it. On the one hand WordPress will still load the Widget. But on the other it won't be able to load the injected services (here: SomeRepository) until they are really used.
Read more about the new YAML structure and other topics in the documentation.