laranail/package-tools
Composer 安装命令:
composer require laranail/package-tools
包简介
Runtime base library for building Laravel packages — fluent Package builder + abstract PackageServiceProvider with attribute-driven discovery, package-tools.doctor, and isolation testing.
README 文档
README
Runtime base library for building Laravel packages.
A fluent Package builder and an abstract PackageServiceProvider your
package extends, in the spirit of spatie/laravel-package-tools. On top of
that base it adds attribute-driven discovery, a set of package-tools.*
Artisan commands, abstract HTTP controllers, and a testing harness.
Status: v0.1.0, the first public release.
Contents
- Requirements
- Installation
- Quick start
- What you get
- Artisan commands
- Attribute discovery
- Documentation
- Local development
- Provenance
- Sister packages
- Contributing & security
- License
Requirements
- PHP
^8.3(8.3, 8.4 and 8.5 are supported; CI tests the full8.3 / 8.4 / 8.5matrix) - Laravel
^13.0 - For development: Pest
^3.0, Testbench^11.0, Larastan^3.0
Installation
composer require laranail/package-tools
The service provider is auto-discovered, so the package-tools.* commands are
available as soon as the package is installed.
Quick start
Extend PackageServiceProvider and describe your package in
configurePackage():
use Simtabi\Laranail\PackageTools\Package; use Simtabi\Laranail\PackageTools\PackageServiceProvider; final class FooServiceProvider extends PackageServiceProvider { public function configurePackage(Package $package): void { $package ->name('vendor/foo') ->hasConfigFile() ->hasViews() ->hasMigration('create_foos_table') ->hasInstallCommand(fn ($command) => $command ->publishConfigFile() ->askToRunMigrations()) ->discoversWithAttributes() ->hasDoctorCheck(FooHealthCheck::class); } }
A complete, runnable example lives in
docs/examples/.
What you get
| Capability | Summary |
|---|---|
Fluent Package builder |
Spatie-compatible surface: name(), hasConfigFile(), hasViews(), hasViewComponents(), hasInertiaComponents(), hasViewComposer(), sharesDataWithAllViews(), hasTranslations(), hasAssets(), hasRoute(), hasMigration(), runsMigrations(), discoversMigrations(), hasCommand(), hasInstallCommand(), publishesServiceProvider(). |
| Attribute discovery | discoversWithAttributes() scans src/ for #[AsArtisanCommand], #[AsRoute], and #[AsViewComposer] and registers them for you. |
| Artisan commands | laranail::package-tools.doctor, .sbom, .audit, .ide-helper (see below). |
| HTTP controllers | Optional WebController / ApiController base classes for package routes. |
| Testing harness | Testing\IsolatedTestCase — Testbench wrapper with in-memory SQLite, sync queue, and schema/command assertions. |
| Runtime services | SystemService, HttpConfigurationService, and ErrorStorageService, bound by the provider and resolvable from the container. |
The full reference is in docs/ — see Documentation.
Artisan commands
Registered automatically via package auto-discovery.
| Command | Purpose | Options |
|---|---|---|
php artisan laranail::package-tools.doctor |
Run every registered DoctorCheck; non-zero exit on any failure. |
--json, --strict |
php artisan laranail::package-tools.sbom |
Emit a CycloneDX 1.5 JSON SBOM for composer.lock. |
--output=, --print |
php artisan laranail::package-tools.audit |
Query OSV.dev for advisories in composer.lock; non-zero exit on any advisory. |
--no-dev, --json, --timeout= |
php artisan laranail::package-tools.ide-helper |
Generate Facade classes from #[AsFacade] contracts with @method docblocks. |
--source=, --output= |
Commands follow the laranail::<package-slug>.<command> naming used across the
laranail family (the :: separator is enabled by the package's base command —
see CONTRIBUTING.md).
Attribute discovery
use Simtabi\Laranail\PackageTools\Attributes\AsArtisanCommand; use Simtabi\Laranail\PackageTools\Attributes\AsRoute; use Simtabi\Laranail\PackageTools\Attributes\AsViewComposer; use Simtabi\Laranail\PackageTools\Attributes\AsFacade; #[AsArtisanCommand(signature: 'foo:run', description: 'Run the foo task')] class FooCommand extends Command {} #[AsRoute(method: 'GET', uri: '/foo')] #[AsRoute(method: 'POST', uri: '/foo', name: 'foo.create', middleware: ['web'])] class FooController {} #[AsViewComposer(views: ['layouts.app', 'partials.header'])] class AppViewComposer {}
See docs/tools/attribute-discovery.md.
Documentation
Hosted at opensource.simtabi.com/package-tools/docs/
(product page: opensource.simtabi.com/package-tools/).
The same pages live under docs/:
Guides
- Installation — requirements, install, auto-registration
- Configuration — the fluent
Packagebuilder and lifecycle hooks - Architecture — how the runtime is put together
- Services reference — the service and support classes
Tools & features
- package-tools.doctor — health checks
- package-tools.sbom — CycloneDX SBOM
- package-tools.audit — OSV.dev advisory scan
- package-tools.ide-helper — Facade generation from
#[AsFacade] - Attribute discovery —
#[AsArtisanCommand],#[AsRoute],#[AsViewComposer] - Command naming — the
laranail::<slug>.<command>separator, the baseCommand, andSupportsNamespacedNames - HTTP controllers —
WebControllerandApiController - IsolatedTestCase — the testing harness
- Runtime services —
SystemService,HttpConfigurationService,ErrorStorageService
Examples
- Runnable examples — a cohesive
Acme\Hellopackage that demonstrates every feature end to end: the fluent builder and lifecycle hooks, all four discovery attributes, namespaced commands, theWebController/ApiControllerbases, doctor checks, the runtime services and consumer traits, package seeders, the install-command flow, and anIsolatedTestCasetest
Local development
bash .scripts/init.sh # verify PHP >= 8.3, run composer install, smoke-check composer setup # alias for .scripts/init.sh composer test # run the Pest suite composer test-coverage # run with coverage composer lint # Pint + PHPStan + Rector (dry run) composer pint-fix # apply Pint formatting composer rector-fix # apply Rector transformations composer audit # composer security audit
.scripts/init.sh is the only shell script in the repo; everything else runs
through Composer.
Provenance
The open API surface (hasConfigFile(), hasViews(), the lifecycle hooks,
and friends) is intentionally compatible with
spatie/laravel-package-tools
(MIT). Code is copyright Simtabi LLC; see LICENSE.
Sister packages
laranail/package-scaffolder— Artisan generator that scaffolds new packages on top ofpackage-tools.laranail/database-tools— standalone Laravel database utilities; no dependency onpackage-tools.laranail/laranail— Simtabi's Laravel utility toolbox.
Contributing & security
- CONTRIBUTING.md — workflow, coding standards, command naming.
- SECURITY.md — how to report a vulnerability.
- CODE_OF_CONDUCT.md — community expectations.
- CHANGELOG.md — release history.
License
MIT. See LICENSE.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-17