Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support external PHP dependencies #253

Open
kasparsd opened this issue Oct 19, 2020 · 0 comments
Open

Support external PHP dependencies #253

kasparsd opened this issue Oct 19, 2020 · 0 comments

Comments

@kasparsd
Copy link
Contributor

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:

  1. 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.

  2. 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 the wp-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.

Acceptance criteria

Implementation brief

QA testing instructions

Demo

Changelog entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant