Roots Discourse

Adding zip url to composer.json

Hi guys, I need to ask if i’m doing this right with Bedrock and Composer.

There are some plugins that I download as zip.
For example, a plugin called dynamic-featured-image is not listed in wppackagist.org thus i need to download and link it manually.

So in composer.json, I add something like this:


...
    "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    },
    {
      "type": "package",
      "package": {
        "name": "myplugins/dynamic-featured-image",
        "version": "3.5.2",
        "type": "wordpress-plugin",
        "dist": {
          "type": "zip",
          "url": "https://dl.dropboxusercontent.com/u/xxxx/myplugins/dynamic-featured-image.3.5.2.zip"
        }
      }
    },
    

But then below that, I am also adding something like this also in composer,json

...
    "require": {
    "php": ">=5.6",
    "composer/installers": "~1.0.12",
    "vlucas/phpdotenv": "^2.0.1",
    "johnpbloch/wordpress": "4.7",
    "oscarotero/env": "^1.0",
    "roots/wp-password-bcrypt": "1.0.0",
    "composer/installers": "~1.0.12",
    "vlucas/phpdotenv": "^2.0.1",
    "johnpbloch/wordpress": "4.6",
    "oscarotero/env": "^1.0",
    "roots/wp-password-bcrypt": "1.0.0",
    "myplugins/dynamic-featured-image": "3.5.2",
    
  },

Is this the correct way to install it effectively or it’s better to put the plugin in the plugins folder later after the installation?
I just think that it will be a hassle for updating the version numbers 2 times…

How to ignore version and tell Composer to just grab the zip from the url given?

Thanks for helping!

It’s on wpackagist.

"wpackagist-plugin/dynamic-featured-image": "^3.5.2"
1 Like

ops, looks like no results is displayed if i just search dynamic featured image

anyway with wpackagist it’s ok but how about the zips … what’s the correct way?
I’ve seen some similar questions but can’t seem to find the practical way…

It would be nice to set a folder in dropbox as repositories, dump all my zips there and inside composer.json, list out all the zips as something like this

"my-dropbox-folder/dynamic-featured-image": "^3.5.2"

:slight_smile: thanks for helping!

Did you try searching the Composer documentation for ‘zip’?

https://getcomposer.org/doc/05-repositories.md

yup, Artifact seems to be the one that would work. But i don’t really understand what does it mean by this example …

Each zip artifact is just a ZIP archive with composer.json in root folder:

unzip -l acme-corp-parser-10.3.5.zip

composer.json
...

composer.json

{
    "repositories": [
        {
            "type": "artifact",
            "url": "path/to/directory/with/zips/"
        }
    ],
    "require": {
        "private-vendor-one/core": "15.6.2",
        "private-vendor-two/connectivity": "*",
        "acme-corp/parser": "10.3.5"
    }
}

The initial way you included the zip looks to be correct. Something similar to:

{
    "name": "smarty/smarty",
    "version": "3.1.7",
    "dist": {
        "url": "http://www.smarty.net/files/Smarty-3.1.7.zip",
        "type": "zip"
    }
}

But if the plugin exists on packagist (as most plugins found on wordpress.org do), you can simplify it by just including the packagist reference as noted by @QWp6t

"wpackagist-plugin/dynamic-featured-image": "^3.5.2"

That will make it easy for you change the version number as needed and run composer update

As far as if there is a way to include a self or externally hosted premium plugin, for example, without having to update version numbers in both places, Composer allows a lot of flexibility for putting approximate versions (i.e. "myplugins/dynamic-featured-image": ~"3.5").

If you’re looking to host all your private/premium plugins and reference them the way you would reference packagist items, consider Private Packagist.

1 Like