wp-foo-bar
wp-foo-bar copied to clipboard
Support external PHP dependencies
Feature description
It would be great to support other PHP libraries as dependencies in projects created from the wp-foo-bar
template. It would also enable modular design where some of the existing features such as the docblock hook API or the autoloader can be decoupled into standalone libraries that can be used in other projects such as themes, sites, etc.
This requires that we address the following issues:
-
Namespace isolation for external libraries to ensure there are no conflicts with other plugins/themes/projects using the same dependencies. This is especially important for plugins hosted on WP.org and used on a variety of site setups.
This can be solved by libraries such as https://github.com/humbug/php-scoper (used by the Yoast SEO plugin and the Google Site Kit plugin) https://github.com/coenjacobs/mozart or https://github.com/TypistTech/imposter-plugin.
-
Bundling of dependencies when creating the plugin package. Note that the development dependencies shouldn't be included in the release package.
Both Yoast SEO and Google Site Kit use a dedicated dependency directory for the scoped dependencies instead of the
/vendor
directory.
All of this can be added without requiring it to be used by default when creating a new plugin from the template.
Overall this feature would provide the following benefits:
-
Enable the re-use of existing PHP libraries in projects created from this template. Most of the PHP-related development tooling is already added as Composer dependencies so enabling the same re-use for regular dependencies would help with pulling in code in a consistent and reliable way.
-
Enable modular design where features provided by the
wp-foo-bar
can be developed outside of thewp-foo-bar
project and re-used on other projects. For example, we could have a generic library to build settings pages or a helper to load JS scripts asynchronously. The success of reusable JS packages has proven the value of this approach.
Do not alter or remove anything below. The following sections will be managed by moderators only.