Pixelairport's avatar

vendor:publish vars on workbench:build not working

I use orchestra testbench and in my testbench.yaml I have:

...
  build:
    - asset-publish
    - create-sqlite-db
    - db-wipe
    - vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
    - migrate-fresh
...

But --provider="Spatie\Permission\PermissionServiceProvider" ist not used, when I use workbench:build. When I only use vendor:publish in testbench.yaml, I will be asked what provider to use. Then it works. I can select Spatie\Permission\PermissionServiceProvider.

But how can I preselect the provider in my testbench.yaml? Also wenn I use vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" in my terminal it works.

0 likes
4 replies
LaryAI's avatar
Level 58

The issue is that commands in the build section of testbench.yaml are interpreted as simple strings and may not handle complex console argument parsing (like --provider=...), particularly with quoting. The argument may not be passed correctly to the underlying Artisan call during the testbench build process.

Solution: Use array notation for the command and its arguments

Instead of the single string command, use array format in testbench.yaml. For example:

build:
  - asset-publish
  - create-sqlite-db
  - db-wipe
  - ['vendor:publish', '--provider=Spatie\Permission\PermissionServiceProvider', '--force']
  - migrate-fresh

Things to note:

  • The command and each argument are separated in the array.
  • --force is often needed to skip interactive prompt (optional, but recommended).
  • This syntax ensures each argument is passed as intended and matches the syntax for how orchestra/testbench calls commands behind the scenes.

Reference:
See the Orchestra Testbench build section reference.

Summary:
Use array notation in your testbench.yaml to pass provider and other arguments to the vendor:publish command during automated build steps.

Pixelairport's avatar
- ['vendor:publish', '--provider=Spatie\Permission\PermissionServiceProvider', '--force']

is also not working.

Pixelairport's avatar

I just thought it is a good idea to create a command and use:

$this->call('vendor:publish --provider=Spatie\Permission\PermissionServiceProvider --tag=migrations');

But this shows also an error:

Command "vendor:publish --provider=Spatie\Permission\PermissionServiceProvider --tag=migrations" is not defined. Did you mean one of these?  

  ⇂ vendor:publish

So it seems there is the same problem. It think maybe it is just a syntax problem, but cant find a solution.

Pixelairport's avatar
Pixelairport
OP
Best Answer
Level 12

Ok... I have the solution:

$this->call('vendor:publish', ['--provider' => 'Spatie\Permission\PermissionServiceProvider']);

Please or to participate in this conversation.