0

Having a few issues here with composer and any help would be really appreciated.

I am working with a WP multi site ( it's actually VIP ) but his makes no difference.

I have a composer.json file in the root of wp-content

My requirement is that i use composer to install a plugin from a remote repo and locating in wp-content/plugins. This in it's self i have managed to do defining my plugin as a vcs as below

"repositories":[
        {
            "type": "vcs",
            "url": "https://github.com/newsuk/nuk-wp-okta-plugin.git"
        }
    ], 

In addition i am using "composer/installers": "~1.0" a relocating the plugin as below

  "extra": {
    "installer-paths":  {
        "plugins/nuk-wp-okta-plugin": [
          "newsuk/nuk-wp-okta-plugin"
        ]
      }
    }

However, although this is defined as a package, i have to be able to run the composer.json that exists in the root of the plugin/package and install the /vendor directory inside the plugin. Sharing the vendor directory throughout wp-content from root is not an option for reasons related to VIP config and deploy.

I have mupltiple requirements for this as well and so what i will want to end up with is something like

wp-content 
   plugins
      nuk-wp-okta-plugin
         composer.json
         vendor/
      plugin2
         composer.json
         vendor/
      plugin3
         composer.json
         vendor/

I know this seems highly irregular but its a need to requirement and i additionally do NOT want to run composer install for every plugin on the build

So in short is there a way to install a package ( or something similar ) that will auto run inside the package directory the composer.json file and position the /vendor/ directory inside the directory rather than the root composer file.

  • 1
    I'm not sure how do you expect this should work. If 2 separate plugins require the same dependency, where do you want to put it? How autoloading initialization should work in this case. And what are the "reasons related to VIP config and deploy"? – rob006 Jul 15 '20 at 19:12
  • i want composer to be individually installed on each plugin. Autoloading would run exactly as it usually does inside each plugin. The reason it's an issue with VIP is that yes, ideally i would share dependencies ( all be it that will throw issues are there are many in house developed plugins that don't necessarily want to share dependencies ) ... – Steve Mason Jul 16 '20 at 05:44
  • VIP restrict the directories you can mount on the server in wp-content. i have limited scope to create a shared dependency folder. I can put into themes , images, or plugins and thats it... If i deliver in one or the other structurally it feels wrong ie the have a shared dependency folder inside themes thats used by plugins or vice versa... The shared dependency issue i mentioned is also somewhat a problem. As the plugin development has been done separately for many sites it's not necessarily viable to for them to all share and at present there could be a big development upgrade required – Steve Mason Jul 16 '20 at 05:50
  • Installing dependencies for all extensions separately will be a massive source of problems, see https://stackoverflow.com/questions/50144816/3rd-party-dependency-conflict-in-developing-wordpress-plugin. I would rather try to create meta mu-plugin which will hold shared dependencies and root `composer.json` for this website. Or just include all dependencies in plugins itself (probably prefixed by php-scoper), so they will not require `composer install` step (all free plugins already work in that way, since WordPress does not support Composer). – rob006 Jul 16 '20 at 10:31

0 Answers0