hyperf/contract
Core contracts for Hyperf: a set of lightweight PHP interfaces that define common behaviors across the framework (DI, events, middleware, serialization, etc.). Helps decouple components, improve testability, and keep implementations swappable.
Illuminate\Contracts) for caching, queues, auth, etc., making this package redundant unless there’s a strategic need for Hyperf integration.CacheInterface vs. Hyperf\Contract\CacheInterface).RedisCache) would still need to be managed.Illuminate\Container and Hyperf’s Hyperf\Di are incompatible. Resolving Hyperf\Contract\CacheInterface in Laravel would require:
Mockery) may require custom test doubles or interface shims.CacheInterface, QueueWorkerInterface)? If so, which should be the single source of truth?Assessment & Gap Analysis
Illuminate\Contracts) and identify gaps where Hyperf’s contracts could add value.Hyperf\Contract\CacheInterface vs. Illuminate\Contracts\Cache\Store.Pilot Integration (Low-Risk Module)
Hyperf\Contract\CacheInterface and Illuminate\Contracts\Cache\Store).Adapter Layer Development
class HyperfCache implements Illuminate\Contracts\Cache\Store {
protected $hyperfCache;
public function __construct(Hyperf\Contract\CacheInterface $cache) {
$this->hyperfCache = $cache;
}
public function get($key) { return $this->hyperfCache->get($key); }
// ... delegate other methods
}
$this->app->bind(
Illuminate\Contracts\Cache\Store::class,
HyperfCache::class
);
Full Adoption (Phased Rollout)
$this->app->bind(
Hyperf\Contract\AuthInterface::class,
App\Services\HyperfAuthService::class
);
Testing & Validation
Mockery support for Hyperf contracts).Documentation & Training
OnRequest in Laravel").composer version constraints to resolve:
"require": {
"psr/cache": "^1.0 || ^2.0",
"react/event-loop": "^1.0"
}
Hyperf\Event) differs from Laravel’s (Illuminate\Events). If using event contracts:
| Phase | Task | Dependencies | Risks |
|---|---|---|---|
| 1 | Contract Mapping | Audit existing Laravel contracts. | Misalignment with Hyperf’s contracts. |
| 2 | Adapter Design | Define facades/wrappers for critical contracts. | DI resolution failures. |
| 3 | Pilot Module | Integrate in a low-risk module (e.g., logging). | Limited visibility into broader impact. |
| 4 | DI Integration | Configure Laravel’s container to resolve Hyperf contracts. | Container conflicts, performance overhead. |
| 5 | Testing | Verify mocking, dependency injection, and runtime behavior. | Testing gaps, edge cases. |
| 6 | Documentation | Update architecture docs and |
How can I help you explore Laravel packages today?