Roots Discourse

Bedrock mu-plugin autolader ignoring wpackagist

I am adding the wp-retina-2x plugin via composer and can successfully install this by adding it to the require hash in the composer file.

I do however want to have this instead as an mu-plugin but moving it from require into the "extra":"installer-paths":"web/app/mu-plugins/{$name}/" has no affect and the plugin is not installed. I get no errors:

  "extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin", "roots/soil:^3.7", "wpackagist-plugin/wp-retina-2x:dev-trunk"],
      "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
      "web/app/themes/{$name}/": ["type:wordpress-theme"]
    }

roots/soil installs without issue.

I have also tried the following variations with no change:

"wpackagist-plugin/wp-retina-2x:*"
"wpackagist-plugin/wp-retina-2x:^5.0.5"

Do I have anything wrong or am I misunderstanding the autoloader?

Thank you

Same here, thought I could append my plugins to the mu-plugins stuff. Soil works fine, the wpackagist-plugins and my CPT plugin don’t…

Guess it has to do with the missing composer-file in the regular WordPress-plugins?

Soil is a package with its type set to wordpress-plugin. Since it implements composer/installers we can override its type.

Or are all the plugin sitting in the mu-plugins-folder automatically being recognized and installed upon deployment? If so then why would I add Soil here?

Could someone shed some light on this?

Thanks!

*bump

Nobody? Still haven’t found a way on how to push / deploy mu-plugins properly, they are being ignored on a Trellis deploy if I just place them in the folder and I cannot add them via composer like so:

"extra": {
  "installer-paths": {
    "web/app/mu-plugins/{$name}/": [
      "type:wordpress-muplugin",
      "roots/soil:3.7.3", // --> THIS WORKS
      "wpackagist-plugin/safe-svg:1.6.1", // --> NOT WORKING
      "wpackagist-plugin/otf-regenerate-thumbnails:0.3", // --> NOT WORKING
      "wpackagist-plugin/media-credit:3.2.0", // --> NOT WORKING
    ],
    "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
    "web/app/themes/{$name}/": ["type:wordpress-theme"]
  },
}

UPDATE
I’ve just discovered another thread with regards to this but this is from 2014 and since then the autoloader seems to have landed so I guess it is obsolete…?

Hey @evance I actually figured out the syntax and forgot to update this thread! heres the relevant section, as I have it configured in composer.json:

"require": {
  "php": ">=5.6",
  "composer/installers": "^1.4",
  "vlucas/phpdotenv": "^2.0.1",
  "johnpbloch/wordpress": "4.9.4",
  "oscarotero/env": "^1.1.0",
  "roots/wp-password-bcrypt": "1.0.0",
  "roots/soil": "*",
  "wpackagist-plugin/wp-retina-2x": "*",
  "wpackagist-plugin/wordpress-seo": "*",
  "wpackagist-plugin/contact-form-7": "*"
},
"require-dev": {
  "squizlabs/php_codesniffer": "^3.0.2"
},
"extra": {
  "installer-paths": {
    "web/app/mu-plugins/{$name}/": [
      "type:wordpress-muplugin", "roots/soil",
      "type:wordpress-muplugin", "wpackagist-plugin/wp-retina-2x",
      "type:wordpress-muplugin", "wpackagist-plugin/wordpress-seo",
      "type:wordpress-muplugin", "wpackagist-plugin/contact-form-7"
    ],
    "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
    "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"
  ]
}

As you can see, the plugins need to be referenced both in require and under installer-paths=>mu-plugins. As well as this, each one must have a preceding “type:wordpress-muplugin” in the array list

4 Likes

Awesome!! Thanks so much for the clarification, works like charm now.

(You might want to close this thread and mark your answer as solution…)

Great, thanks, helped me too! But the plugin stays under /plugins/ folder as well when running composer update (as well as creating a folder under mu-plugins/ which is correct).

What should I do to properly remove it via composer without removing folder manually? Should only be installed under mu-plugins not under both right?

Composer is only aware of the paths you tell it to install to now: it has no knowledge of a path you told it to install to in the past. You will have to manually delete the files in plugins.

Hey, thanks, I figured! :slight_smile: