mitsuki/contracts
最新稳定版本:v1.0.2
Composer 安装命令:
composer require mitsuki/contracts
包简介
Core interfaces and abstractions for the Mitsuki framework.
README 文档
README
Mitsuki Contracts is a set of core interfaces and abstractions for the Mitsuki framework. By using these contracts, you can build decoupled, testable, and interchangeable components.
🚀 Features
- Decoupling: Depend on abstractions, not implementations (Dependency Inversion Principle).
- Standardization: Unified error handling and validation flow.
- Lightweight: Zero external dependencies (only PHP 8.1+).
📦 Installation
You can install the package via Composer:
composer require mitsuki/contracts
🛠 Usage
Validation Contract
To create a request that supports self-validation, implement the ValidatableRequestInterface. This ensures your application remains consistent by forcing a validateOrFail flow.
use Mitsuki\Contracts\Validation\ValidatableRequestInterface; use Mitsuki\Contracts\Validation\Exceptions\ValidationException; class RegisterRequest implements ValidatableRequestInterface { public function validateOrFail(): void { // Your logic: if validation fails... // throw new MyValidationException("Invalid data"); } public function getErrors(): array { return ['email' => ['The email field is required.']]; } }
Exception Handling
All framework-specific exceptions implement the ExceptionInterface, allowing for clean global catching:
try { $request->validateOrFail(); } catch (\Mitsuki\Contracts\Exceptions\ExceptionInterface $e) { // Catch any Mitsuki related exception }
👤 Author
- Zgenius Matondo - zgeniuscoders@gmail.com
📄 License
The MIT License (MIT). Please see License File for more information.
Message de Commit
docs: create professional README with installation and usage guides
Souhaitez-vous que je génère également le fichier LICENSE (MIT) avec votre nom pour compléter le dépôt ?
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-16