d

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567
ouroffice@aware.com

 

KMF

Simplifying Service Providers With Laravel Package Tools

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.

I think you’ll agree that this package can streamline common use-cases found in package service providers:

use SpatieLaravelPackageToolsPackageServiceProvider;
use SpatieLaravelPackageToolsPackage;

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.

Learn More

You can learn more about this package, get full installation instructions, and view the source code on GitHub. At the time of writing, the best place to get documentation is the project’s readme file.

Freek Van der Herten also wrote about Simplifying service providers in Laravel packages, which is an excellent deep-dive of why this package exists and how it can clean up your service providers.

Filed in:
News
/
packages


Credit: Source link

Previous Next
Close
Test Caption
Test Description goes like this