monkeyscloud/monkeyslegion-contracts

Lightweight contracts (interfaces & abstract bases) for the MonkeysLegion framework — zero framework coupling.

Maintainers

Package info

github.com/MonkeysCloud/MonkeysLegion-Contracts

pkg:composer/monkeyscloud/monkeyslegion-contracts

Statistics

Installs: 6

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.0 2026-04-22 01:05 UTC

This package is auto-updated.

Last update: 2026-04-22 01:08:25 UTC


README

License: MIT

Lightweight contracts (interfaces & abstract base classes) for the MonkeysLegion framework.

This package exists so that external packages and third-party bundles can implement framework contracts (like ServiceProviderInterface) without pulling in the entire monkeyscloud/monkeyslegion meta-package.

Installation

composer require monkeyscloud/monkeyslegion-contracts

Dependencies

Package Version
php ^8.4
psr/container ^2.0

That's it. No framework packages required.

Provided Contracts

ServiceProviderInterface

The contract for modular service providers. Implement this to register DI definitions, specify context (http, cli, all), and hook into the container boot lifecycle.

use MonkeysLegion\Contracts\ServiceProviderInterface;
use Psr\Container\ContainerInterface;

class MyPackageProvider implements ServiceProviderInterface
{
    public function getDefinitions(): array
    {
        return [
            MyService::class => fn() => new MyService(),
        ];
    }

    public function provides(): array
    {
        return [MyService::class];
    }

    public function context(): string
    {
        return 'all';
    }

    public function isDeferred(): bool
    {
        return false;
    }

    public function boot(ContainerInterface $container): void
    {
        // Post-build initialization
    }
}

AbstractServiceProvider

Convenience base class with sensible defaults — only getDefinitions() is required:

use MonkeysLegion\Contracts\AbstractServiceProvider;

class MyPackageProvider extends AbstractServiceProvider
{
    public function getDefinitions(): array
    {
        return [
            MyService::class => fn() => new MyService(),
        ];
    }
}

How It Fits Together

Layer Package What it does
Contract monkeyslegion-contracts Defines ServiceProviderInterface
Framework monkeyslegion Discovers & boots providers via ProviderScanner
Your Package your-vendor/your-package Implements the interface, requires only contracts
App monkeyslegion-skeleton Registers package providers in Bootstrap

External packages require only monkeyslegion-contracts. The consuming application registers them during bootstrap:

Application::create($basePath)
    ->withProviders([YourPackageProvider::class])
    ->run();

License

MIT © MonkeysCloud