Best way to install private/paid plugins with Composer?


#1

Hi guys,

I was wondering if anyone had installed any private/paid plugins using Composer and if so how you did it.

I’m trying to install one of the addons for Advanced Custom Fields (Options Page) which isn’t publicly available (you have to pay for the download). So far I’ve tried installing it as a third-party plugin hosting the plugin privately on Bitbucket but I keep getting “invalid zip file”, before I dive into this any further has anyone had any better luck with any other methods?

Thanks,

Paul


Problem with plugins not available through wpackagist
What happens to the site dot Git directory on production deploy
VirtualBox. Trellis. Ansible. Bedrock All Set. Now what
WordPress and plugins updates in production server after deployment
#2

Is the zip invalid in composer or on Bitbucket?

Assuming the former, if the zip you downloaded contained no .git folder then you may need to create your own tags on Bitbucket for the versioning to work. Alternatively you can opt for adding the package as a vcs/git instead of a zip.


#3

Thanks for the quick response Nick,

I think I was setting the version wrong, I was setting a version number when it needs to be the branch (?), your link to the composer docs pointed me in the right direction.


For future reference for others, this worked:

Your project’s composer.json needs:

{
      "type": "vcs",
      "url": "git@bitbucket.org:accountname/reponame.git"
}

in your repositories list,

"accountname/reponame":"dev-master"

listed as a requirement and your external plugin only needs to contain:

{
    "name": "accountname/reponame",
    "version": "master",
    "type": "wordpress-plugin",
    "dist": {
        "url": "git@bitbucket.org:accountname/reponame.git",
        "type": "git"
    }
}

First attempt at premium plugin / bitbucket / composer setup
#4

Thanks for that.

For plugins that you don’t want to live on a “public” private cloud like Bitbucket, it seems like Satis offers a pretty simple method to provide packagist abilities for self-hosted repos. I’m hoping to go that route shortly.


#5

Could you do an example of using private repos, with satis or something else. I have few paid themes that I need and would want something like this:

  • have ENV variable which tells where To download those
  • have another composer-private.json To locate the private parts.
  • use sshkeys authentication To download them from bitbucket/etc

I would want to publish my code To github as is but only people working on same project could use the private parts.

I need this because I don’t use capistrano but git-push-deploys.

Thanks! This project is really awesome and full of happiness, unicorns and rainbows :slight_smile:


#6

Most of what you want is covered by this example in the official Composer docs: https://getcomposer.org/doc/articles/handling-private-packages-with-satis.md

Your ideal workflow is a little different but I’m not sure it’s all needed. As long as you have your own Satis repository running which defines your private repositories/packages, the only people who will be able to download them are those with the proper SSH keys.


#7

I Needed a slightly different setup to get my repo to be installed via composer; hopefully this will help someone who may be stuck:

My project’s "repositories" key in the composer.json file has:

    {
      "type": "vcs",
      "url": "https://bitbucket.org/accountname/reponame.git"
}

in "require" i have:

"accountname/reponame":"dev-master"

And in my repo composer.json file I needed to change "dist" into "source" or else it would not work:

{
    "name": "accountname/reponame",
    "version": "master",
    "source": {
        "url": "https://bitbucket.org/accountname/reponame.git",
        "type": "git"
    }
}

finally, while doing the update:

composer update -v --prefer-source

First attempt at premium plugin / bitbucket / composer setup
Sage theme as a package dependency in composer.json
#8

I’m trying to include a MU-Plugin thats hosted on my private bitbucket.

I’ve added the following to my projects composer.json

{
    "type": "vcs",
    "url": "git@bitbucket.org:kjprince/disable-year-month-uploads.git"
    }, 

In the require section I’ve added this:

"kjprince/disable-year-month-uploads": "dev-master"

When I do composer update it fails and shows the following error:

[LogicException]
  Downloader "Composer\Downloader\GitDownloader" is a source type downloader and can not be used to dow
  nload dist

I updated my composer.json to use source instead of dist and I get the error below:

Skipped branch master, Package kjprince/disable-year-month-uploads's source key should be specified as {"type": ..., "url": ..., "reference": ...},
{"url":"git@bitbucket.org:kjprince\/disable-year-month-uploads.git","type":"git"} given.

My plugin contains the following composer.json

{
    "name": "kjprince/disable-year-month-uploads",
    "version": "master",
    "type": "wordpress-muplugin",
    "source": {
        "url": "git@bitbucket.org:kjprince/disable-year-month-uploads.git",
        "type": "git"
    }
}

Anyone know what’s going on here?


Themes & MU-plugins: Nested repositories, GIT Submodules or something entirely different?
#9

Does the kjprince/disable-year-month-uploads repo contain a composer.json? If not, you need to specify more information like this:

{
      "type": "package",
      "package": {
        "name": "kjprince/disable-year-month-uploads",
        "version": "master",
        "type": "wordpress-plugin",
        "source": {
          "type": "vcs",
          "url": "git@bitbucket.org:kjprince/disable-year-month-uploads.git"
        },
        "require" : {
          "composer/installers": "v1.0.16"
        }
      }
    }

#10

Hi all, I have a question regarding Satis, composer and private plugins.

I have a plugin called x-shortcodes from vendor themeco, I’ve put the entire code of the plugin in our private git repo: ssh://git@code.ttss.ch:2222/diffusion/SATIS/satis.git

The plugin PHP code is in the themeco/x-shortcodes/ folder inside the git repo.

Inside satis.json I’ve put:

{
    "name": "TTSS",
    "homepage": "http://satis.ttss.ch",
    "repositories": [
        { "type": "vcs", "url": "ssh://git@code.ttss.ch:2222/diffusion/SATIS/satis.git" },
        {
                "type": "package",
                "package": {
                        "name": "themeco/x-shortcodes",
                        "version": "2.3.3",
                        "source": {
                                "url": "ssh://git@code.ttss.ch:2222/diffusion/SATIS/satis.git:/themeco/x-shortcodes/",
                                "type": "git",
                                "reference": "origin/master"
                        },
                        "autoload": {
                            "psr-4": { "themeco\\x-shortcodes\\": "themeco/x-shortcodes/" }
                            }
                }
        }
    ],
    "require-all": true
}

when I execute composer update x-shortcodes get’s installed fine (fetches it from git as it should do) but places everything in the folder vendor/themeco/x-shortcodes/themeco/ which is wrong, I neet to specify which folder to get from git, he actually pulls all the git root.

To make things short I would place all my private plugins into one repo, under <vendor>/<plugin-name> and serve them that way. Suggestions? Thanks.


#11

think I resolved it using zip files:

{
  "name": "TTSS",
  "homepage": "http://satis.ttss.ch",

  "repositories": [
    {
      "type": "package",
      "package": {
        "name": "themeco/x-shortcodes",
        "description": "Includes all shortcode functionality for X",
        "keywords": ["themeco","x-shortcodes"],
        "license": "LGPL-3.0+",
        "authors": [
          {
            "name":"Themeco",
            "homepage":"http://theme.co"
          }
        ],
        "version": "2.3.3",
        "dist": {
          "url": "http://satis.ttss.ch/files/x-shortcodes.zip",
          "type": "zip"
        },
        "type": "wordpress-plugin",
        "require": {
            "php": ">=5.3.2",
            "composer/installers": "*"
        }
      }
    }
  ],
  "require-all": true
}

Advanced Custom Fields, paid plugins and composer
Installing paid plugins and themes from themeforest and envato
#12

Yeah, Composer won’t pull from a subdirectory within a Git repo. In fact it’s not even possible using git clone. See http://stackoverflow.com/questions/600079/is-there-any-way-to-clone-a-git-repositorys-sub-directory-only


#13

Perfect, thanks @swalkinshaw everything works this way, now I’ll just protect the package repo with some basic auth and it should be fine.


#14

For WPML users: http://wpml.org/forums/topic/composer-support/#post-419855


#15

I think this is the best way.


#16

After a quick search I was unable to find any references to managing plugins with composer from https://github.com/wp-premium

Soo, I felt like this thread would be a good place to bring it up…

So, I got the following to work with no issue:

{
        "type": "package",
        "package": {
            "name": "wp-premium/gravityforms",
            "type": "wordpress-plugin",
            "version": "1.9.17.5",
            "dist": {
                "url": "https://github.com/wp-premium/gravityforms/archive/master.zip",
                "type": "zip"
            }
        }
}

and then simply ran $ composer require "wp-premium/gravityforms"

While the above worked, is it the correct approach? or should i be doing something different? (note: i’d really rather not maintain a multitude of private repos, but would if its the correct approach)

note: i also tried the same format above but with “git” as the type and changing the url to:

git@github.com:wp-premium/gravityforms.git

…along with some other variations but had no luck with any

Thanks in advance!


#17

There’s a new project by the creator of Composer called Toran Proxy.
This might solve most of the issues here.

https://toranproxy.com/


#18

@wdeer that’s awesome.

Any idea who maintains the wp-premium repo?

@vdrnn that looks really cool too.

But correct me if I’m wrong guys– with toranproxy you’d need to manually update the proxy repo every time the plugin updates, and with wp-premium the repo owner updates it?

If that’s the idea of wp-premium does, that seems incredibly useful. But then you’ll probably still need to update the .json manually (to update version #s)? Or is there an automated process for this?

Edit: -“gist” +“idea”, gist is probably a bad word to use now that it’s a proper noun. :slightly_smiling:


#19

Yep, you would

Composer packages work off Git tags, so you could just tag each release as the version number.


#20

@kalenjohnson very true! That’s awesome.

Which leads me to my next point:

@wdeer, your problem with using the remote git repo is that your .json syntax is wrong. Try something like this:

{
      "type": "vcs",
      "url": "git@github.com:wp-premium/gravityforms.git"
    },

@kalenjohnson, that ^^ should work right?


How I use PostTypes to make Post Types