Laravel Package Tools
A fluent PackageServiceProvider that removes the boilerplate from building Laravel packages.
Repository Health
Technical Analysis
Laravel Package Tools, maintained by Spatie, provides a base PackageServiceProvider and a fluent Package configuration object that let package authors register config files, migrations, views, Blade and Inertia components, routes, translations, assets, and console commands with a single chained call. Instead of hand-writing repetitive boot and register logic in every package, you describe your package declaratively and the provider wires up publishing tags, loading, and lifecycle hooks for you.
It is the foundation used by nearly all of Spatie’s own Laravel packages and by thousands of community packages, and it pairs with the spatie/package-skeleton-laravel starter to give a consistent, opinionated project structure that just works with the provider out of the box.
What You Get
- An abstract
PackageServiceProviderwith a singleconfigurePackage()entry point - A fluent
Packagebuilder for config, migrations, views, routes, translations, assets, and commands - Automatic registration of publishing tags so users can run
vendor:publishwithout extra wiring - A composable
InstallCommandfor guided package setup (publish assets, run migrations, star repo) - Lifecycle hooks (registering/registered/booting/booted) for custom package logic
Common Use Cases
- Bootstrapping the service provider for a new open-source Laravel package
- Registering publishable config, migrations, and views without repetitive boilerplate
- Shipping an interactive install command that sets up your package in the host app
- Standardizing provider structure across a suite of related packages
Under The Hood
Architecture - The package is built around one abstract class, PackageServiceProvider, which composes a dozen Process* traits (ProcessConfigs, ProcessMigrations, ProcessViews, ProcessCommands, etc.) via src/Concerns/PackageServiceProvider. A parallel set of Has* traits on the Package value object (src/Concerns/Package) captures the fluent declarations, and the provider’s register()/boot() methods walk that configuration to load resources and register publish groups.
Tech Stack - Pure PHP 8.1+, depending only on illuminate/contracts (Laravel 10-13) so it stays framework-light. Dev tooling uses Pest 2-4 with Orchestra Testbench for provider testing, Mockery, and PHPUnit code coverage.
Code Quality - The codebase is small, trait-composed, and heavily tested: roughly 90+ test files under tests/ exercise each resource type against a real service provider using Testbench. Naming is consistent (hasX/processX), invariants like the required package name are enforced with a dedicated InvalidPackage exception.
API Design - The public surface is a single configurePackage(Package $package) method with a discoverable fluent builder; method names read like the feature they enable (hasConfigFile, hasMigration, hasInstallCommand). Getting started requires almost no boilerplate, and the companion package-skeleton repo makes the expected directory layout obvious.