Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Tetravalence's avatar

What is the difference between tag and provider option in vendor:publish command?

Could someone please explain me the difference between tag and provider option in vendor:publish command issued with php artisan? Does this snippet of code

$this->publishes([
            dirname(dirname(__FILE__)).
                '/config/mypackage.php' => config_path('mypackage.php'),
        ], 'mypackage');

work exactly like this and why?

$this->publishes([
            dirname(dirname(__FILE__)).
                '/config/mypackage.php' => config_path('mypackage.php'),
        ]);
0 likes
2 replies
bobbybouwmann's avatar
Level 88

So the provider tag is for the full service provider. So let's say your service provider provides some config files like your example, but it also provides some migrations for example. So when you run vendor:publish --provider=SomeProvider it will do all of the publishes in that service provider.

When you use tag you can group things together. For example a package can have multiple migration files or multiple config files. Or maybe even some optional files that give extra features. When you tag them you don't have to publish them right away. So when you use the tag option you only publish what belongs to that tag group.

When you run vendor:publish without provider or tag it will loop over all service providers and return that for you!

Let me know if this is clear for you!

1 like

Please or to participate in this conversation.