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 to quickly register and publish config, views, translations, assets, routes, migrations, commands, view components/composers, and an optional interactive install command.

View on GitHub
Deep Wiki
Context7

Tools for creating Laravel packages

Frequently asked questions about Laravel Package Tools
How do I quickly set up a Laravel package with config, migrations, and views using spatie/laravel-package-tools?
Extend `PackageServiceProvider` and use the fluent `configurePackage()` method to declare your package’s resources. For example, call `hasConfigFile()`, `hasViews()`, and `hasMigration()` to auto-register them. The package handles publishing and service provider setup under the hood.
Does spatie/laravel-package-tools support Laravel 10+ features like auto-discovery?
Yes, the package works seamlessly with Laravel’s auto-discovery (introduced in Laravel 8+). Your package’s service provider will be automatically registered if it follows Laravel’s naming conventions (e.g., `YourPackageServiceProvider`). No manual configuration is needed in the host app.
Can I customize the publishable paths for my package’s assets or config files?
Yes, the package provides methods like `publishesConfigFile()` or `publishesAssets()` with custom paths. Override the default behavior by passing a closure or string path in the `configurePackage()` method. For example, `->publishesConfigFile('custom/path')`.
How do I add an Artisan command to my package with spatie/laravel-package-tools?
Use the `hasCommand()` method in `configurePackage()` to register your command class. The package automatically handles command discovery and registration. For example: `->hasCommand(YourCommand::class)`. No manual `Artisan::register()` calls are needed.
Will this package work with Laravel Mix or Vite for asset compilation?
Yes, the package supports assets via the `hasAssets()` method. It integrates with Laravel Mix/Vite by default, allowing you to publish and compile assets like CSS or JavaScript. Just ensure your asset paths are correctly configured in the `configurePackage()` method.
How do I create an installer command (e.g., `your-package:install`) for my package?
Use the `hasInstallCommand()` method and chain install steps like `publishConfigFile()`, `publishMigrations()`, or `askToStarRepoOnGitHub()`. The package generates a ready-to-use Artisan command with prompts for common setup tasks, reducing boilerplate.
Does spatie/laravel-package-tools enforce a specific directory structure for packages?
The package follows Laravel’s conventions (e.g., `src/`, `resources/`) but allows customization. You can override paths or ignore defaults by passing arguments to methods like `hasViews()` or `hasMigrations()`. For example, `->hasViews('custom/path')`.
How do I test a package built with spatie/laravel-package-tools in a Laravel app?
Test by requiring your package in a fresh Laravel installation via Composer. Use `php artisan vendor:publish` to publish resources, then verify functionality. For migrations, run `php artisan migrate`. The package’s auto-discovery ensures no manual service provider registration is needed.
Are there alternatives to spatie/laravel-package-tools for Laravel package development?
Alternatives include `orchestra/package` or `nWidart/laravel-modules`, but spatie/laravel-package-tools stands out for its simplicity and focus on Laravel’s native features. It avoids heavy abstractions and integrates tightly with Laravel’s ecosystem, making it ideal for modern packages.
How do I handle version conflicts between spatie/laravel-package-tools and Laravel?
The package is designed to work with Laravel 8–11. Monitor Laravel’s release notes for breaking changes (e.g., auto-discovery updates). Test your package against multiple Laravel versions in CI/CD pipelines. If conflicts arise, check the package’s changelog or GitHub issues for patches.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai