laranail/package-tools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest version on Packagist Tests Static analysis License: MIT

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

  • PHP ^8.3 (8.3, 8.4 and 8.5 are supported; CI tests the full 8.3 / 8.4 / 8.5 matrix)
  • 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

Tools & features

Examples

  • Runnable examples — a cohesive Acme\Hello package that demonstrates every feature end to end: the fluent builder and lifecycle hooks, all four discovery attributes, namespaced commands, the WebController/ApiController bases, doctor checks, the runtime services and consumer traits, package seeders, the install-command flow, and an IsolatedTestCase test

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

Contributing & security

License

MIT. See LICENSE.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固