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.
Cache\Store, Queue\ShouldQueue), making implementations swappable and testable.Dtoable, Http\Builder) are generic enough to work across PHP projects using similar patterns.composer require dragon-code/contracts) with zero configuration required.symfony/http-kernel (v6/7/8), which is already a Laravel dependency, reducing friction.| Risk | Mitigation | Severity |
|---|---|---|
| Overhead for Small Projects | Contracts add zero runtime cost; only useful if leveraging DDD/clean architecture. | Low |
| Laravel Version Lock-in | Actively supports Laravel 11/12; minor updates may require version alignment. | Medium |
| Limited Adoption (0 Dependents) | No proven ecosystem, but DragonCode’s other packages (e.g., helpers) rely on these contracts. |
Medium |
| Symfony Dependency Bloat | symfony/http-kernel is already in Laravel; no additional bloat. |
Low |
| Breaking Changes in Minor Updates | Follows semver; minor updates (e.g., 2.x.x) may add methods but won’t break existing code. |
Low |
Architecture Goals:
Laravel Version Strategy:
Adoption Scope:
Ecosystem Integration:
helpers)? If yes, contracts like Dtoable are required.Testing & Mocking:
Cache\Store instead of concrete implementations.)Performance Impact:
Long-Term Maintenance:
| Component | Fit | Notes |
|---|---|---|
| Laravel 11/12 | Excellent (explicit support in v2.24.0+) | No compatibility issues; follows Laravel’s evolution. |
| Symfony 6/7/8 | Good (dependency via symfony/http-kernel) |
Already present in Laravel; minimal overhead. |
| PHP 8.3+ | Required (no backward compatibility for older PHP) | Ensure CI/CD and local environments meet this requirement. |
| Clean Architecture | Ideal (enforces dependency inversion) | Critical for DDD, hexagonal, or onion architecture. |
| Modular Monoliths | Strong (shared contracts between modules) | Reduces coupling between independently deployable components. |
| Microservices | Good (if using shared contracts for inter-service communication) | Requires standardized contract adoption across services. |
| Legacy Laravel | Poor (<11 not supported) | Avoid for projects stuck on Laravel 10 or older. |
Assessment Phase:
ShouldQueue, Dtoable).Pilot Integration:
Cache\Store instead of App\Contracts\CacheInterface).Incremental Adoption:
Dtoable for serialization).ShouldQueue, ShouldBeUnique).Http\Builder, Cache\Ttl).Enforcement:
Deprecation:
| Scenario | Compatibility | Workaround |
|---|---|---|
| Laravel 10 or older | ❌ No support | Stick to custom interfaces or upgrade Laravel. |
| Symfony 5.x | ⚠️ Partial | May require dependency overrides (not recommended). |
| PHP <8.3 | ❌ No support | Upgrade PHP or avoid this package. |
| Non-Laravel PHP projects | ✅ Possible | Use only generic contracts (e.g., Dtoable, Cache\Store). |
| Existing custom implementations | ✅ Replaceable | Implement DragonCode’s interfaces alongside old ones, then migrate. |
Pre-requisites:
Critical Path:
dragon-code/contracts in the root project and key packages.ShouldQueue, ShouldBeUnique).Cache\Store, Http\Builder).Parallel Work:
Post-Integration:
| Aspect | Impact | Mitigation |
|---|---|---|
| Dependency Updates | Minor updates may add methods (e.g., rememberForever in v2.21.0). |
Use Composer’s update command with --dry-run to test. |
| Breaking Changes | Rare; follows semver. Major versions (e.g., 3.0.0) may require review. | Pin to a specific minor version (e.g., ^2.25) in composer.json. |
| DragonCode Ecosystem | Future packages may ** |
How can I help you explore Laravel packages today?