Laravel - Package Development - Public Assets
Your package may have assets such as JavaScript, CSS, and images. To publish these assets to the application's public
directory, use the service provider's publishes
method. In this example, we will also add a public
asset group tag, which may be used to easily publish groups of related assets:
/**
* Bootstrap any package services.
*
* @return void
*/
public function boot()
{
$this->publishes([
__DIR__.'/../public' => public_path('vendor/courier'),
], 'public');
}
Now, when your package's users execute the vendor:publish
command, your assets will be copied to the specified publish location. Since users will typically need to overwrite the assets every time the package is updated, you may use the --force
flag:
php artisan vendor:publish --tag=public --force