Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Package Tools

Laravel Package Tools Laravel Package

spatie/laravel-package-tools

PackageServiceProvider base class for Laravel packages that simplifies registering config files, migrations, views, translations, routes, commands, assets, and view components, with publishable resources and a configurable install command.

View on GitHub
Deep Wiki
Context7

spatie/laravel-package-tools gives Laravel package authors a fluent PackageServiceProvider base class that registers config files, migrations, views, translations, routes, commands and assets from a single configurePackage() method. Rather than repeating boilerplate registration and publishing logic in every package, you simply declare what your package offers and the tools handle the rest.

  • Fluent configuration through a chainable Package object
  • Publishing made easy for config files, assets, migrations and service providers
  • Install command builder with publishing, provider registration and GitHub star prompt
  • Extras included: view components, view composers, shared view data and translations
Frequently asked questions about Laravel Package Tools
How do I install spatie/laravel-package-tools in a Laravel package?
Install it with Composer using composer require spatie/laravel-package-tools. Then create a service provider that extends the PackageServiceProvider base class and implement configurePackage(Package $package). Laravel package discovery can pick up the provider, so host apps usually do not need manual registration.
What can the PackageServiceProvider register for a Laravel package?
It can register config files, migrations, views, translations, routes, commands, assets, view components, view composers, and shared view data. It also makes those resources publishable through Laravel's vendor:publish workflow. You configure these features fluently in configurePackage().
How do I publish a Laravel package config file with laravel-package-tools?
Call hasConfigFile() in configurePackage() and optionally use the install command to publish it. The package handles the publish tag naming and vendor:publish registration for you. In production, run config:cache only after verifying the package config is present.
Does spatie/laravel-package-tools support Laravel 10 and Laravel 11?
The package is actively maintained and tested against Laravel LTS releases, with broad Laravel version support. For exact version constraints, check the Composer requirements on Packagist for the release you plan to use. Version 1.93.3 is a patch release with no breaking API changes.
How does laravel-package-tools handle migrations in a package?
Use hasMigration('create_package_tables') to register a package migration. The package can discover and load migrations automatically, so host apps can run them like normal Laravel migrations. Be disciplined with migration names and dependencies to avoid conflicts with host-app schema.
Is spatie/laravel-package-tools compatible with config:cache in production?
Yes. Since version 1.93.3, package config file checks are skipped when Laravel's configuration is cached, aligning with the standard php artisan config:cache deployment flow. This reduces the previous risk of local-versus-staging config differences. You should still test both cached and uncached modes in CI.
How do I add an install command to a Laravel package using PackageServiceProvider?
Use hasInstallCommand() and configure the InstallCommand with methods such as publishConfigFile(), publishAssets(), publishMigrations(), and copyAndRegisterServiceProviderInApp(). This gives host-app developers a guided Artisan install experience. You can also prompt them to star the repository on GitHub.
Can I customize laravel-package-tools beyond the default package structure?
Yes. You can override configurePackage() and use lifecycle hooks such as register() and booted() to adapt behavior. The package is opinionated about directory structure but extensible without forking. For unusual architectures, confirm the conventions fit before adopting it.
What are alternatives to spatie/laravel-package-tools for building Laravel packages?
Alternatives include writing a custom Laravel service provider that manually registers config, migrations, views, routes, and publishable assets. You can also start from Spatie's package-skeleton-laravel, which is preconfigured for laravel-package-tools. The main trade-off is boilerplate versus adopting an opinionated package structure.
How do I test a Laravel package that uses laravel-package-tools?
Test the service provider inside a Laravel application or a package test harness, and verify each registered resource works after boot. Spatie's package-skeleton-laravel provides a preconfigured starter template with tests. Also run CI against both cached and uncached config to catch production-only issues.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections