-
Notifications
You must be signed in to change notification settings - Fork 94
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
How to distribute Herbert based plugin? #80
Comments
+1 for this question. The only way I can think of is committing the vendor directory. As for conflicts, you could run a find and replace, adding a prefix. Obviously not ideal as it you'd essentially be restricted to that version of the library (until/unless you update and run another find/replace). |
My idea is to commit only composer.json and composer.lock. Build Scrip can be simple:
|
Not sure about distributing via the wordpress plugin directory, but I've been including herbert plugins using a main composer.json requiring "type": "wordpress-plugin", to the herbert plugin's composer.json I've changed /plugin.php to do some ugly detection of the correct vendor directory to use. Would love to know a better way: // Prefer our vendordir
$vendor_dir = __DIR__ . '/vendor/';
if ( file_exists( $vendor_dir . '/autoload.php' ) ) {
require_once $vendor_dir . '/autoload.php';
require_once $vendor_dir . '/getherbert/framework/bootstrap/autoload.php';
} else {
if ( ! defined( 'WP_CLI' ) && class_exists( '\Composer\Autoload\Classloader' ) ) {
$reflector = new ReflectionClass( '\Composer\Autoload\Classloader' );
$vendor_dir = str_replace( 'composer/ClassLoader.php', '', $reflector->getFileName() );
// composer autoloader already done, so just
require_once $vendor_dir . '/getherbert/framework/bootstrap/autoload.php';
}
}
// Store vendor dir
if ( function_exists( 'herbert' ) ) {
herbert()->instance( 'vendor_dir', $vendor_dir );
} |
@onnimonni This is clearly related to #115 since publishing the plugin to the Wordpress plugin directory would make it easy to distribute it (even via composer). Do you agree? |
Let's say I want to make a plugin and distribute it on the Wordpress codex, or even sell it as a premium plugin from my own website. Considering a large percentage of Wordpress users do not use or don't have the ability to use composer, what is a sane method or best practice for deploying plugins built with Herbert?
The only thing I can think of is to commit the vendor directory to my git repo and distrubute it with the plugin, but for a number of obvious reasons this doesn't seem ideal.
Also, what about conflicts with other composer based plugins that might require the same libraries? What about deployment side by side with other herbert based plugins?
The text was updated successfully, but these errors were encountered: