Skip to content

Instantly share code, notes, and snippets.

@tangrufus
Last active October 16, 2018 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tangrufus/e817dd7e35fd53ba184a262e421671d2 to your computer and use it in GitHub Desktop.
Save tangrufus/e817dd7e35fd53ba184a262e421671d2 to your computer and use it in GitHub Desktop.
Making wp plugin zip out of composer repo

Making wp plugin zip out of composer repo

Assumptions

  1. not using Bedrock
  2. you understand the risks of dependency version conflicts
  3. plugin main file is loading vendor/autoload.php
// The main plugin file.

/**
 * Plugin Name: My Plugin
 * some other plugin headers...
 */
 
// some lines of code...

// These 3 lines are important!
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
    require_once __DIR__ . '/vendor/autoload.php';
}

// some lines of code...

Steps

  1. go to the repo on github.com
  2. navigate to the specific commit or tag
  3. download the zip file, see: github-zip.jpg
  4. unzip it on your computer
  5. rename the folder name to match the plugin name
  6. $ composer install --no-dev --prefer-dist --optimize-autoloader --no-suggest
  7. zip it
  8. done

Important

  1. this is the last resort
  2. not always work
  3. your computer's PHP version should match the remote server one
@tangrufus
Copy link
Author

On macOS:
Normal zipping doesn't work!

Use: $ zip -r -X myplugin-1.2.3.zip my-plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment