Config merging was there in Yii 2 advanced app template. It was moved to composer plugin. And yes, this thing is kind of magical but alternative is manual config merging that I don’t like. As for caching, DB schema cache was not that magical compared to what is there in Symfony.
Thank you for that. I was thinking a lot about it and sorry if I hadn’t communicated clearly why it went the way it went. In case of not having Cache decorator:
- We’ll have to copy-paste what’s in the decorator for every cache backend then: array, memcached, wincache, apcu etc.
- In case of need to use third party PSR cache backend, user would be required to implement adapter first. Now it could be used right away.
- Current structure potentially increases non-Yii usage of cache packages which is beneficial to potential contributions.
Another thing with cache is that it’s a library that isn’t strictly tied to Yii itself. It could be used separately. As for refactoring, I guess you are referring more to splitting individual drivers into their own packages. There are benefits in doing that:
- Ability to release separately from other code.
- Ability to specify platform dependencies in
- Potentially more usage by PHP community as a whole thus more contribution.
So yes, indeed in case of cache it become a bit more complicated in initial configuration but
$cache = new Cache(new ApcuCache());
$cache = new ApcuCache();
is a very low price to pay for benefits gained.
Also such trade-offs are mainly introduced where PSR interoperability is considered or libraries are meant to be used out of context of Yii as a framework. In
yii- packages that’s not the case (or at least I’m trying hard to keep these extra layers under control).
Reviewing more from Yii 3 would be certainly helpful.