Problems with using vendor:publish when Acorn installed as a plugin

As a continuation of our discussion at Sage 10.0.0-beta.3 released - #11 (Sorry @ben :sweat_smile:):

I am not a bedrock user and wasn’t able to use vendor:publish using Acorn as a plugin.

After multiple trial and error, I got it working only with the previous Sage configuration by doing the composer require roots/acorn and readding the post-autoload-dump script to composer.json:

  "scripts": {
    "lint": [
      "phpcs --extensions=php --standard=PSR12 app"
    ],
    "post-autoload-dump": [
      "Roots\\Acorn\\ComposerScripts::postAutoloadDump"
    ]
  },

@ramiroazar this is an answer to your entry in the above topic. Thanks for the post-autoload-dump tip!!

If anyone knows how to make it work with the autoload dump as a plugin, please point us in the right direction!!

What does this mean exactly? Please provide the full output from your terminal

The output is correct, but if you install any package (poet, acf composer, you name it), it won’t give you the vendor:publish option for this packages. To be able to replicate, just install any of this packages with acorn as a plugin (I am using the php-8.0 release) and run wp acorn vendor:publish.

I think the reason it’s behind the fact that the plugin doesn’t have a composer.json and post-autoload-dump, but my knowledge of acorn is too limited to assess it correctly.

Please provide the full output from your terminal

In a new project from scratch, using acorn as a mu-plugin, and requiring log1x/poet it gives this:

Which provider or tag's files would you like to publish?:
  [0] Publish files from all providers and tags listed below
  [1] Provider: Roots\Acorn\Providers\AcornServiceProvider
  [2] Tag: acorn

I tried wp acorn vendor:publish --tag=acorn or selecting number 0 or number 1, and it sets up the config folder but it still doesn’t work.

In the documentation, it says to execute wp acorn vendor:publish --tag=acorn:init, which also doesn’t expand the list.

In the other project, where I required acorn from the sage folder and added post-autoload-dump, it gives me:

 Which provider or tag's files would you like to publish?:
  [0] Publish files from all providers and tags listed below
  [1] Provider: Log1x\AcfComposer\Providers\AcfComposerServiceProvider
  [2] Provider: Log1x\Poet\PoetServiceProvider
  [3] Provider: Log1x\SageSvg\SageSvgServiceProvider
  [4] Provider: Roots\Acorn\Providers\AcornServiceProvider
  [5] Tag: acorn
  [6] Tag: config
 > 

I hope this is what you were looking for!

As a temporary fix, you can publish the config directory, and add Log1x\Poet\PoetServiceProvider to config/app.php in the providers section.

2 Likes

I can confirm it works, thanks!!

Just as an example (all acorn providers can be extracted manually from composer.lock)

        /*
         * Package Service Providers...
         */
        Genero\Sage\WooCommerce\WooCommerceServiceProvider::class,
        Log1x\AcfComposer\Providers\AcfComposerServiceProvider::class,
        Log1x\Poet\PoetServiceProvider::class,
        Log1x\HtmlForms\HtmlFormsServiceProvider::class,
        Log1x\SageSvg\SageSvgServiceProvider::class,