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

Contracts Laravel Package

dragon-code/contracts

Dragon Code Contracts provides a lightweight set of PHP interfaces (contracts) you can reuse across any project to standardize key behaviors, improve type-safety, and keep implementations decoupled. Ideal as a shared dependency for packages and applications.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Standardization Across Laravel Projects: Eliminates fragmentation in multi-team environments by providing consistent contracts for caching, queues, DTOs, and HTTP operations, ensuring predictable behavior across services.
  • Clean Architecture & Dependency Inversion: Aligns with hexagonal architecture and Domain-Driven Design (DDD) by offering well-defined interfaces (e.g., Cache\Store, Queue\ShouldQueue), decoupling implementations from business logic.
  • Accelerated Development of Reusable Packages: Reduces onboarding time for internal libraries by eliminating the need to define custom interfaces for Laravel-specific patterns (e.g., rememberForever, ShouldBeUnique).
  • Strategic Ecosystem Adoption: Justifies integration with DragonCode’s broader tooling (e.g., dragon-code/helpers) by providing foundational contracts like Dtoable, ensuring seamless compatibility with advanced features like serialization.
  • Build vs. Buy for Abstractions: Shifts focus from maintaining custom contracts to leveraging maintained, framework-aligned interfaces, reducing technical debt and maintenance overhead.
  • Modular Monolith Refactoring: Provides a contract-first foundation for decomposing monolithic Laravel applications into modular components, ensuring interoperability between independently deployable modules.
  • Testability & Mocking: Simplifies unit testing by offering well-defined interfaces for caching, queues, and HTTP operations, reducing reliance on concrete implementations and improving test coverage.
  • Future-Proofing for Laravel 11/12: Ensures long-term maintainability with active support for the latest Laravel versions, aligning with modern PHP frameworks and reducing migration risks.

When to Consider This Package

Adopt this package if:

  • Your Laravel-based project prioritizes scalability and maintainability, particularly for caching, queues, or DTOs, and seeks to avoid reinventing abstractions.
  • You’re using Laravel 11/12 or Symfony 6/7 and want future-proof contracts with minimal maintenance overhead.
  • Your team follows clean architecture, DDD, or hexagonal principles and needs explicit interfaces for domain-driven components (e.g., actions, migrations, HTTP clients).
  • You’re building reusable internal packages or modular Laravel applications and require framework-agnostic contracts to ensure compatibility across projects.
  • You’re integrating with DragonCode’s ecosystem (e.g., dragon-code/helpers) and need contracts like Dtoable for serialization or other advanced features.
  • You want to reduce boilerplate for common Laravel patterns (e.g., rememberForever in caching, job deduplication with ShouldBeUnique).

Look elsewhere if:

  • Your project doesn’t use Laravel or PHP, as the package is Laravel-centric with PHP-only interfaces.
  • You need concrete implementations (e.g., service providers, cache drivers) rather than just interfaces.
  • Your team resists dependency inversion or prefers trait-based solutions over interfaces for flexibility.
  • You’re building a public API/library where backward compatibility is critical—this package has no dependents and frequent minor updates, which may introduce breaking changes.
  • You require highly specialized contracts beyond caching/queues/DTOs/HTTP (e.g., domain-specific business rules).
  • Your project uses Laravel <11 and risks compatibility gaps with Symfony 6/7 dependencies, as the package actively updates for newer Laravel versions.

How to Pitch It (Stakeholders)

For Executives: *"This package standardizes interfaces for Laravel’s most repetitive patterns—caching, queues, and data transfer—saving development time and reducing technical debt. By adopting these contracts, we can:

  • Enforce consistency across teams, eliminating redundant interface definitions and reducing onboarding time for new developers.
  • Accelerate feature delivery by eliminating boilerplate for common Laravel tasks, allowing engineers to focus on business logic.
  • Future-proof our architecture with clean abstractions that align with DragonCode’s ecosystem, ensuring compatibility with tools like dragon-code/helpers. It’s a low-risk, high-reward decision: zero runtime cost, pure type hints, and immediate benefits for maintainability, scalability, and developer productivity."*

For Engineering/Architecture Teams: *"TheDragonCode’s contracts enable decoupled, testable, and reusable components by providing pre-built interfaces for Laravel’s critical systems. Key benefits include:

  • Dependency Inversion: Replace cache drivers, queue handlers, or HTTP clients without modifying dependent code, making the system more modular.
  • Testability: Mock interfaces like Cache\Store or ShouldQueue for isolated unit tests, improving code quality and reducing integration risks.
  • Ecosystem Alignment: Required for dragon-code/helpers (e.g., Dtoable for serialization), ensuring seamless integration with other DragonCode packages.
  • Clean Architecture: Enforce dependency inversion for actions, migrations, and domain objects, aligning with DDD and hexagonal architecture.

Integration is effortless:

  1. Install via Composer: composer require dragon-code/contracts.
  2. Implement interfaces in existing classes (e.g., class MyDto implements Dtoable).
  3. Gain compile-time safety, reduced boilerplate, and consistency across the codebase.

Ideal for teams adopting microservices, modular monoliths, or clean architecture in Laravel."*

For Developers: *"Stop reinventing the wheel for DTOs, caching, queues, and HTTP clients. This package gives you ready-to-use contracts for:

  • DTOs: Implement Dtoable for seamless serialization with dragon-code/helpers.
  • Caching: Use Cache\Ttl or rememberForever without writing custom interfaces.
  • Queues: Add ShouldQueue or ShouldBeUnique to jobs for built-in deduplication.
  • HTTP: Standardize domain handling with Http\Builder contracts.

How to start:

  1. Install: composer require dragon-code/contracts.
  2. Implement interfaces in your classes (e.g., class MyJob implements ShouldQueue).
  3. Benefit from type safety, reduced boilerplate, and immediate alignment with clean architecture principles.
  4. Leverage built-in Laravel 11/12 compatibility without additional configuration.
  5. Future-proof your codebase with contracts that evolve alongside Laravel’s ecosystem.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4