fuelphp-storage / dependency

Fuel Dependency package based on League\Container

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Order of extensions

sagikazarmark opened this issue · comments

When adding extensions to a resource in some cases the order of extensions matters. For example in case of parsers in display package there is a chance that the custom extension will be applied before the View Manager. (This is caused by the order of prefixes from composer, by default the prefixes are arranged by Z-A)

Possible fix: prioritization of extensions

How would you do that, given the fact that Composer sorts them?

I am thinking about setting dependencies between services and service providers. It is possible that a service provider relies on a service that has not been already added, so before adding the provided services to the container, all providers should be fetched and added to the container in the order of the dependency tree. The actual implementation is still a question, but we have to bypass Composer sort somehow.

Possible solution: introduce proxies and lazy loading.

https://github.com/Ocramius/ProxyManager

Looks like an interesting appoach.

If integrated in Dependency it might even speed up the entire framework, because no single object will be instantiated unless actually called.

Actually it is not true: proxy objects will be instantiated, but they are usually much less heavier than the real objects. However the lazy loading still has a big benefit: having the object without instantiation. Could help for example in display where the view manager must be injected in each parser.

It is not really a dependency issue, but a foundation one, since the application adds service providers dynamically.

A probable solution could be to grab providers in any Fuel namespace and add them first, and everything else later.

Closing this for now, will reopen it in foundation.