laravel-packages

Package development and extraction of reusable code. Use when working with package development, code reusability, or when user mentions packages, composer packages, extract package, reusable code, package development.

⭐3stars🔀0forks📁View on GitHub🕐Updated Dec 18, 2025

When & Why to Use This Skill

This Claude skill streamlines Laravel package development and the extraction of reusable code, empowering developers to transition from monolithic structures to modular, maintainable architectures. It provides standardized templates and integrates industry-leading tools like Spatie Laravel Data, Saloon, and Pest to ensure that extracted packages are scalable, well-tested, and ready for distribution via Composer.

Use Cases

  • Extracting recurring business logic or utility patterns into standalone Composer packages to be shared across three or more Laravel projects.
  • Scaffolding a professional package directory structure including Service Providers, DTOs, and Actions to ensure architectural consistency.
  • Integrating advanced data handling and API client builders like Spatie Laravel Data and Saloon into custom packages for robust external service management.
  • Implementing automated testing suites and architecture tests using Pest to maintain high code quality and stability in shared internal libraries.
namelaravel-packages
descriptionPackage development and extraction of reusable code. Use when working with package development, code reusability, or when user mentions packages, composer packages, extract package, reusable code, package development.

Laravel Packages

Package development: extracting reusable patterns for use across projects.

Related guides:

When to Extract

Extract to package when:

  1. Pattern used in 3+ projects
  2. Code is stable and well-tested
  3. Pattern has clear boundaries
  4. Maintenance cost justified

→ Complete extraction guide: package-extraction.md

Package Structure

my-package/
├── src/
│   ├── PackageServiceProvider.php
│   ├── Actions/
│   ├── DTOs/
│   └── ...
├── tests/
├── composer.json
└── README.md

Use semantic versioning. Test packages independently. Document clearly.

Core Packages (Always)

Spatie Laravel Data

composer require spatie/laravel-data
  • DTOs with casting, validation, transformers
  • Test factory support

Spatie Model States

composer require spatie/laravel-model-states
  • State machine pattern
  • State transitions with dedicated classes

Spatie Query Builder

composer require spatie/laravel-query-builder
  • Filter, sort, include relations via query strings
  • API-friendly querying

Saloon

composer require saloonphp/saloon saloonphp/laravel-plugin
  • Elegant API client builder
  • Testable external service integrations

Pest

composer require pestphp/pest pestphp/pest-plugin-laravel --dev
  • Expressive testing framework
  • Architecture tests

Optional Packages

Laravel Sanctum

composer require laravel/sanctum

When: API authentication needed

Stancl Tenancy

composer require stancl/tenancy

When: Multi-tenant application

Spatie Settings

composer require spatie/laravel-settings

When: Application-level settings needed

Installation Commands

Full Install

composer require \
  spatie/laravel-data \
  spatie/laravel-model-states \
  spatie/laravel-query-builder \
  saloonphp/saloon \
  saloonphp/laravel-plugin

composer require \
  pestphp/pest \
  pestphp/pest-plugin-laravel \
  --dev

./vendor/bin/pest --init

Minimal Install

composer require spatie/laravel-data
composer require pestphp/pest pestphp/pest-plugin-laravel --dev
./vendor/bin/pest --init