Weave Code
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

A base PackageServiceProvider for Laravel package authors. Quickly register and publish config, views, translations, assets, routes, migrations, commands, view components/composers, and install commands—all via a clean, fluent API.

View on GitHub
Deep Wiki
Context7

Tools for creating Laravel packages

Frequently asked questions about Laravel Package Tools
What Laravel versions does `spatie/laravel-package-tools` support?
The package is actively maintained and tested against Laravel’s LTS releases (e.g., 10.x, 11.x). Check the [GitHub repo](https://github.com/spatie/laravel-package-tools) for the latest compatibility matrix, as it often aligns with the newest stable Laravel version.
How do I install and set up `laravel-package-tools` in my Laravel package?
Add the package via Composer: `composer require spatie/laravel-package-tools`. Then extend `PackageServiceProvider` in your package’s service provider and use the fluent `configurePackage()` method to declare resources (configs, migrations, views, etc.). No manual registration is needed if your package uses `hasInstallCommand`.
Can I customize the directory structure beyond Spatie’s opinionated `src/` and `resources/` layout?
The package enforces a standardized structure for consistency, but you can override paths in `configurePackage()` for specific resources (e.g., `hasConfigFile('path/to/custom/config.php')`). However, deviating too much may reduce compatibility with tools like `package-skeleton-laravel` or community templates.
Does `laravel-package-tools` support dynamic package behavior (e.g., runtime config changes)?
The `configurePackage()` method is static, but you can use the `booted()` lifecycle hook in your service provider to modify behavior after Laravel’s bootstrapping. For runtime config changes, publish the config file and use Laravel’s binding system or environment variables.
How does the package handle migrations, and what if my package has complex migration dependencies?
Migrations are auto-discovered via `hasMigration()` with glob patterns (e.g., `create_*_tables.php`). For dependencies, ensure your migrations run in the correct order by naming them logically (e.g., `create_users_table.php` before `add_user_metadata.php`). Avoid relying on host-app migrations in your package’s auto-discovery.
Will using `laravel-package-tools` slow down my package’s boot time or `vendor:publish` commands?
The package is optimized for performance, but heavy use of publishable resources (e.g., many assets or migrations) may add minor overhead. Test in staging to validate. For large packages, consider lazy-loading non-critical resources or splitting them into separate publishable tags.
Can I use this package for non-Laravel PHP projects (e.g., Symfony, Lumen)?
No, `laravel-package-tools` is Laravel-specific and relies on Laravel’s service container, Artisan, and publishable resources. For Symfony or Lumen, consider alternatives like `symfony/flex` or custom Composer scripts.
How do I handle breaking changes if Spatie updates `laravel-package-tools`?
Monitor the [release notes](https://github.com/spatie/laravel-package-tools/releases) for breaking changes. Most updates are backward-compatible, but test thoroughly in a staging environment. Use `composer why-not spatie/laravel-package-tools` to check for dependency conflicts.
Does the package support Inertia.js or Vue.js components, and how do I integrate them?
Yes, use `hasViewComponent()` to register Inertia/Vue components. Ensure your package’s `resources/js` or `resources/views/components` directories are properly structured. The package assumes Laravel’s Inertia integration is already set up in the host app.
What alternatives exist if I need more flexibility than `laravel-package-tools` offers?
For lighter control, use Laravel’s built-in `ServiceProvider` and manually register resources via `mergeConfigFrom`, `loadMigrationsFrom`, etc. For advanced use cases (e.g., dynamic package loading), consider `orchestra/platform` or `nwidart/laravel-modules`, though these add complexity. Evaluate trade-offs based on your package’s needs.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony