Laravel - Package Development - Publishing File Groups
You may want to publish groups of package assets and resources separately. For instance, you might want to allow your users to publish your package's configuration files without being forced to publish your package's assets. You may do this by "tagging" them when calling the publishes
method from a package's service provider. For example, let's use tags to define two publish groups for the courier
package (courier-config
and courier-migrations
) in the boot
method of the package's service provider:
/**
* Bootstrap any package services.
*
* @return void
*/
public function boot()
{
$this->publishes([
__DIR__.'/../config/package.php' => config_path('package.php')
], 'courier-config');
$this->publishes([
__DIR__.'/../database/migrations/' => database_path('migrations')
], 'courier-migrations');
}
Now your users may publish these groups separately by referencing their tag when executing the vendor:publish
command:
php artisan vendor:publish --tag=courier-config