Packagesv1.0
Contracts
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