Plugin installation via Composer: downloaded but not added to the plugins folder

I’ve added a (premium) plugin via composer

"repositories": [
{
      "type": "composer",
      "url": "https://composer.domain.tld/packages.json?authorization=(licensekey)"
    }
]

...
"require": {
    "php": ">=7.1",
    "composer/installers": "^1",
    "vlucas/phpdotenv": "^4",
    "oscarotero/env": "^1",
    "roots/wordpress": "^5",
    "roots/wp-config": "^1",
    "roots/wp-password-bcrypt": "^1",
    "freemius/widget-for-eventbrite-api-premium": "^2.9.3"

...

Locally, no issue. The plugin is properly installed.
On staging, it does not appear in the WP > Plugins interface. It is present in the “vendor” folder though, but not present in the web/app/plugins folder.

Do you have any clue as to what is happening here and how to solve it?
I’ve tried :

  • simply redeploying
  • clearing composer cache on the server (using the web user).
  • rm -rf vendor/* then composer install

Thank you,
Alex

1 Like

This is more than likely due to the plugin’s composer.json type not being set to wordpress-plugin.

You can simply add the package name to the array along with type:wordpress-plugin in installer-paths and it should be good to go.

"web/app/plugins/{$name}/": ["type:wordpress-plugin", "freemius/whatever"],
2 Likes

Makes sense, but I made the change to the composer.json, then composer update to refresh the .lock file, then deployed, and still, the plugin does not get copied into the plugins folder …

I also tried this, on the remote:
composer remove freemius/whatever
composer require freemius/whatever

It went smooth (no error message), but still no go.

Hi, the plugin author here - there is no composer.json in the plugin distribution, so can’t quite understand how that would be an issue?

1 Like

I’d have to see an example of the composer repo json and the plugin composer file then to really wrap my head around what is happening.

In most cases, manually defining it as a wordpress-plugin like my post above should work regardless – so I’m not sure why it wouldn’t be.

Hi!
Thank you, I really appreciate your help. Here is my local composer.json file

{
  "name": "myorg/new.website.tld",
  "type": "project",
  "license": "MIT",
  "description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure",
  "homepage": "https://roots.io/bedrock/",
  "authors": [
    {
      "name": "Scott Walkinshaw",
      "email": "scott.walkinshaw@gmail.com",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "Ben Word",
      "email": "ben@benword.com",
      "homepage": "https://github.com/retlehs"
    }
  ],
  "keywords": [
    "bedrock",
    "composer",
    "roots",
    "wordpress",
    "wp",
    "wp-config"
  ],
  "support": {
    "issues": "https://github.com/roots/bedrock/issues",
    "forum": "https://discourse.roots.io/category/bedrock"
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    },
    {
      "type": "composer",
      "url": "https://composer.deliciousbrains.com"
    },
    {
      "type": "composer",
      "url": "https://composer.freemius.com/packages.json"
    }
  ],
  "require": {
    "php": ">=7.1",
    "composer/installers": "^1",
    "vlucas/phpdotenv": "^4",
    "oscarotero/env": "^1",
    "roots/wordpress": "^5",
    "roots/wp-config": "^1",
    "roots/wp-password-bcrypt": "^1",
    "deliciousbrains-plugin/wp-migrate-db-pro": "^1.9",
    "deliciousbrains-plugin/wp-migrate-db-pro-media-files": "^1.4",
    "deliciousbrains-plugin/wp-migrate-db-pro-cli": "^1.3",
    "deliciousbrains-plugin/wp-migrate-db-pro-theme-plugin-files": "^1.0",
    "wpackagist-plugin/ewww-image-optimizer": "^5.2",
    "wpackagist-plugin/wordfence": "^7",
    "wpackagist-plugin/autodescription": "*",
    "wpackagist-plugin/batcache": "*",
    "wpackagist-plugin/post-smtp": "^2",
    "wpackagist-plugin/password-protected": "^2",
    "roots/soil": "*",
    "wpackagist-plugin/category-posts": "^4",
    "wpackagist-plugin/enable-media-replace": "^3",
    "wpackagist-plugin/regenerate-thumbnails": "*",
    "wpackagist-plugin/safe-svg": "^1",
    "wpackagist-plugin/redis-cache": "^1",
    "wpackagist-plugin/wp-super-cache": "*",
    "soberwp/intervention": "*",
    "freemius/widget-for-eventbrite-api-premium": "^2.9"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "^3.5.4",
    "roave/security-advisories": "dev-master",
    "wpackagist-plugin/query-monitor": "*"
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist"
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": [
        "type:wordpress-muplugin"
      ],
      "web/app/plugins/{$name}/": [
        "type:wordpress-plugin",
        "freemius/widget-for-eventbrite-api-premium"
      ],
      "web/app/themes/{$name}/": [
        "type:wordpress-theme"
      ]
    },
    "wordpress-install-dir": "web/wp"
  },
  "scripts": {
    "post-root-package-install": [
      "php -r \"copy('.env.example', '.env');\""
    ],
    "test": [
      "phpcs"
    ]
  }
}

Maybe you have to use a dedicated composer installer?

If the dependency itself doesn’t have a composer.json that declares its type and depends on composer/installers, adding your own installer-path config as a consumer won’t work. See the last note on this page.

So the plugin author must add a composer.json that declares the plugin as type wordpress-plugin for this to work. Not sure how you’re making it work in your local environment…

2 Likes