pickware / shopware-development

MIT License
0 stars 0 forks source link

Load common libraries / bundles with plugins #2

Closed fixpunkt closed 4 years ago

fixpunkt commented 5 years ago

I've taken a look at how this could be implemented.

Preferably, we'd want to integrate this into the Shopware Next platform. There's two basic approaches how this could be accomplished:

  1. Publish the common dependencies as plugins and have the plugin manager automatically resolve, install and update these based on dependency requirements specified by the plugins. This would effectively turn the plugin manager into a full-fledged package manager, which probably comes at the price of considerable complexity. The advantage of this is that the correct bundle could be resolved at installation time, which means there wouldn't be any overhead when booting the kernel. Also, this would just work with the current class loader setup.
  2. Provide a mechanism for plugins to ship and register additional bundles (including meta-information such as the bundle version) as part of their distribution package. When multiple dependencies ship the same bundle, a resolution algorithm would have to be run. This could be as simple as just using the one with the latest version, or asking each plugin in turn whether it is willing to accept a certain version of a bundle and then picking the one which satisfies all plugins (and de-activating the plugin if no solution is found). This overhead would be incurred during kernel boot. Also, loading the dependencies from the dirs of plugins which ship them would requires registering PSR-4 namespaces dynamically.
fixpunkt commented 5 years ago

I've proposed the general idea to Shopware in the shopware6-pickware channel.

fixpunkt commented 5 years ago

Shopware's Michael T. was originally planning to implement approach 1 by using Composer's PHP API to actually require plugins into the Shopware installation and then have plugin dependencies loaded from an authenticated Satis-compatible repository. This approach proved not to be viable because the require took multiple minutes, which is not acceptable when plugin installation is performed as part of a PHP server request (due to max_execution_time).

We've agreed to make a PR implementing approach 2. This likely requires us to do a PR for #1 first.

fixpunkt commented 4 years ago

Support for this was added in https://github.com/shopware/platform/pull/32.