mitsuki/contracts

Core interfaces and abstractions for the Mitsuki framework.

Maintainers

Package info

github.com/zgeniuscoders/mitsuki-contracts

pkg:composer/mitsuki/contracts

Statistics

Installs: 19

Dependents: 4

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.2 2026-02-20 15:43 UTC

This package is auto-updated.

Last update: 2026-02-20 15:44:19 UTC


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

📄 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 ?