Best way to install private/paid plugins with Composer?

I think this is the best way.

2 Likes

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!

2 Likes

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

https://toranproxy.com/

2 Likes

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

1 Like

Yep, you would

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

1 Like

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

zip is probably faster, but yeah using Git is better IMO as you just need to update the version number rather than the file URL each time.

With a .zip can you do it like this?

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

Or do you have to do it like this?

{
        "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"
            }
        }
}
1 Like

For a long time I added

{
    "type": "git",
    "url": "git@bitbucket.org:your-name/advanced-custom-fields-pro.git"
   },

etc, etc, and just tagged my commits with the new version number.

Now I use Toran Proxy because you can set it up with a cron and it will mirror all your git repos and also packagist too if you want at whatever rate you decide to set the cron job for. So you really only need to push new versions to your private repos and Toran automatically stays in sync.

If you want a super ez way to do zip files check out
https://getcomposer.org/doc/05-repositories.md#artifact

2 Likes

Hi there, if you are fed up of writing / modifying composer.json for your premium or own packages, release-belt from Rarst is a nice solution.

  1. Serve release-belt through a web server of your choice (can be the php embedded one)
  2. Drop your plugins and themes zips in release/wordpress-{plugin,theme}/company/
  3. that’s all

Relase-belt will create a composer.json automatically.

I’m just starting using it on a server on the wild with basic http auth and it works great.

4 Likes

I’m running into problems with this approach when deploying, as I’m not sure how to pass the --prefer-source flag to the deploy script.

Ideally, I’d like to avoid using the --prefer-source flag, but on composer update and deploy, I get the error message:

[LogicException] Downloader “Composer\Downloader\GitDownloader” is a source type downloader
and can not be used to download dist

And I really don’t understand what’s going on and how to get around it (how do you set the private plugin to be “source” rather than “dist”?).

Bedrock composer.json repository code:

    {
      "type": "vcs",
      "url": "git@bitbucket.org:growdigital/advanced-custom-fields-pro.git"
    }

Plugin composer.json:

{
  "name": "growdigital/advanced-custom-fields-pro",
  "type": "wordpress-plugin",
  "source": {
    "type": "git",
    "url": "git!@bitbucket.org:growdigital/advanced-custom-fields-pro.git"
  }
}

And it feels like I’ve tried every variation inbetween!!

I’ve managed to run composer with private repos locally but unfortunately I’m having the same issue when I try do deploy.yml

Loading composer repositories with package information                          
Installing dependencies from lock file                                          
                                                                                
                                                                                
  [LogicException]                                                              
  Downloader "Composer\Downloader\GitDownloader" is a source type downloader    
and can not be used to download dist                                            
                                                                                
                                                                                
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev]        
[--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress]       
[--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a             
|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...        
fatal: [production_host]: FAILED! => {"changed": true, "cmd": ["composer", "inst
all", "--no-ansi", "--no-dev", "--no-interaction", "--no-progress", "--optimize-
autoloader", "--no-scripts"], "delta": "0:00:00.141280", "end": "2016-11-29 05:4
9:38.212958", "failed": true, "rc": 1, "start": "2016-11-29 05:49:38.071678", "s
tderr": "Loading composer repositories with package information\nInstalling depe
ndencies from lock file\n\n                                                     
                                                              \n  [LogicExceptio
n]                                                                              
                   \n  Downloader \"Composer\\Downloader\\GitDownloader\" is a s
ource type downloader and can not be used to download dist  \n                  
                                                                                
                 \n\ninstall [--prefer-source] [--prefer-dist] [--dry-run] [--de
v] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-pr
ogress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--cl
assmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...", "stdout": 
"", "stdout_lines": [], "warnings": []}                                         
        to retry, use: --limit @/vagrant/deploy.retry
1 Like

Got to working!

For reference, I simply removed these lines from the repo’s composer.json

"source": {
    "url": "git@bitbucket.org:gabrielgiordan/my-plugin.git",
    "type": "git"
}

And keep it like this.

{
    "name": "gabrielgiordan/my-plugin",
    "description": "My Plugin",
    "type": "wordpress-plugin",
    "license": "proprietary",
    "authors": [
        {
            "name": "Gabriel Giordano"
        }
    ],
    "require": {
		"composer/installers": "^1.0.6"
	}
}

Deploy worked fine!

3 Likes

This may be of interest:

3 Likes

$60/m is a little steep for most freelancers. Might be a good idea for an agency though.

1 Like

someone has had success with woocommerce premium plugins ?

A lot of premium ones have repos on Github too. Or set up your own for the plugins needed and use the same format as mentioned in this thread.

Thank you for reply @jasperfrumau, but if you set up for your own. You have to update every time the zip file manually. Right?

Yeah. I do this a lot for Formidable and The Events Calendar Pro. It’s a pain but there’s no other option.

DAMN! we have to find a solution :smiley:

1 Like