monkeyscloud/monkeyslegion-contracts
Composer 安装命令:
composer require monkeyscloud/monkeyslegion-contracts
包简介
Lightweight contracts (interfaces & abstract bases) for the MonkeysLegion framework — zero framework coupling.
README 文档
README
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
统计信息
- 总下载量: 306
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-22