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

How to distribute Herbert based plugin? #80

Closed
phredeye opened this issue Oct 20, 2015 · 4 comments
Closed

How to distribute Herbert based plugin? #80

phredeye opened this issue Oct 20, 2015 · 4 comments

Comments

@phredeye
Copy link

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?

@arippberger
Copy link

+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).

@roest01
Copy link

roest01 commented Dec 2, 2015

My idea is to commit only composer.json and composer.lock.
Then use a build server (f.e jenkins) and build a .zip file with vendor inside which can be delivered by
YahnisElsts/plugin-update-checker or a premium updater.

Build Scrip can be simple:

git checkout yourRepo myPluginDirectory
composer.phar install
zip -r plugin.zip myPluginDirectory -x .*

@JacobDorman
Copy link

Not sure about distributing via the wordpress plugin directory, but I've been including herbert plugins using a main composer.json requiring composer/installers and adding

"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 );
}

@jeremyzahner
Copy link

jeremyzahner commented May 23, 2016

@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?

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

5 participants