Laravel Package Tools is a package by Spatie that provides an opinionated base service provider you can use to streamline the registration of your package’s config files, migrations, commands, and more.
Here’s how to simplify service providers in @laravelphp packageshttps://t.co/qKmIO7nUJY
Spoiler: I released a package for that https://t.co/URH2udPbiJ#php #laravel pic.twitter.com/tWCGuE8HG8
— Freek Van der Herten (@freekmurze) January 25, 2021
I think you’ll agree that this package can streamline common use-cases found in package service providers:
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Spatie\LaravelPackageTools\Package;
class YourPackageServiceProvider extends PackageServiceProvider
{
public function configurePackage(Package $package) : void
{
$package
->name('your-package-name')
->hasConfigFile()
->hasViews()
->hasTranslations()
->hasMigration('create_package_tables')
->hasCommand(YourCoolPackageCommand::class);
}
}
Spatie also provides a skeleton Laravel package you can use as a template for your next package project. The Laravel skeleton uses the package tools service provider out of the box.