echo-fusion / contracts
Core interfaces and contracts for the EchoFusion framework, providing shared, standardized interfaces for cross-package interoperability and modular design.
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
- psr/container: ^2.0
- psr/event-dispatcher: ^1.0
- psr/http-message: ^2.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- echo-fusion/codestandard: ^1.0
- friendsofphp/php-cs-fixer: ^3.64
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- v2.0.0
- v1.x-dev
- v1.8.0
- v1.7.0
- v1.6.0
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- v0.x-dev
- v0.1.0
- dev-feat/v2-segregated-router-psr14-plugin-context
- dev-chore/unify-tooling-and-docs
- dev-feat/auth-interfaces
- dev-feat/database-interfaces
- dev-feat/template-interfaces
- dev-feat/module-manager-interfaces
- dev-feat/session-interface
- dev-feat/config-interface
- dev-ci/php-matrix
- dev-fix/restore-route-matcher-interface
- dev-feature/route-loader-interface
This package is auto-updated.
Last update: 2026-10-12 13:54:22 UTC
README
Welcome to the EchoFusion Contracts repository! This package defines the core interfaces and abstractions that are shared across the EchoFusion framework, ensuring consistency and flexibility in how components interact with each other.
Part of EchoFusion, a modular PHP framework built from small packages.
Installation
composer require echo-fusion/contracts
Requirements
- PHP 8.1, 8.2 or 8.3
What is inside
Every interface lives in the namespace EchoFusion\Contracts\<Package>. A package depends on this one instead of on another concrete package, so any implementation can be swapped for another.
| Namespace | Interfaces | Implemented by |
|---|---|---|
AuthManager |
AuthManagerInterface, GuardInterface, StatefulGuardInterface, UserInterface, UserProviderInterface, PasswordHasherInterface |
authmanager |
ConfigManager |
ConfigInterface |
configmanager |
DatabaseManager |
ConnectionInterface, DatabaseManagerInterface |
databasemanager |
EventManager |
EventInterface (a PSR-14 stoppable event), EventManagerInterface (a PSR-14 dispatcher and listener provider) |
eventmanager |
MiddlewareManager |
MiddlewareManagerInterface, MiddlewarePipelineInterface |
middlewaremanager |
ModuleManager |
ModuleInterface, ModuleManagerInterface |
modulemanager |
PluginManager |
PluginInterface (receives the container), PluginManagerInterface |
pluginmanager |
RouteManager |
RouterInterface (find a route), RouteRegistrarInterface (register routes), RouteInterface (immutable definition), RouteMatchInterface, RouteMatcherInterface, RouteLoaderInterface |
routemanager |
ServiceManager |
ServiceManagerInterface, SettableContainerInterface |
servicemanager |
ServiceProvider |
ServiceProviderInterface |
any package that registers services |
SessionManager |
SessionInterface |
sessionmanager |
TemplateManager |
TemplateEngineInterface, TemplateManagerInterface |
templatemanager |
Usage
Implement an interface in your own code, or type-hint it so any implementation can be passed in. For example, a service provider:
use EchoFusion\Contracts\ServiceManager\ServiceManagerInterface; use EchoFusion\Contracts\ServiceProvider\ServiceProviderInterface; class MyServiceProvider implements ServiceProviderInterface { public function register(ServiceManagerInterface $container): void { // Register your services here } public function boot(ServiceManagerInterface $container, array $config): void { // Boot your services here } }
Upgrading from 1.x to 2.0
| Change | What to do |
|---|---|
RouterInterface no longer has get(), post() ... options() |
They moved to RouteRegistrarInterface. Type-hint it where you register routes; the Router of routemanager implements both. |
RouteInterface has no setters |
Routes are values: create them complete (new Route($name, $method, $path, $action, ...)). |
EventManagerInterface is a PSR-14 dispatcher |
Call dispatch($event); trigger() is gone from the interface. detach() is part of it. EventInterface extends PSR-14's StoppableEventInterface. |
PluginInterface::register() receives a container |
register(SettableContainerInterface $container). |
Every other interface is unchanged, so packages that do not use the ones above only need their echo-fusion/contracts constraint widened to ^1.x || ^2.0.
Versioning
Contracts follow semantic versioning. A new interface or class is a minor release. Adding a method to an existing interface is a breaking change and needs a new major version.
Testing
composer test
Credits
License
The MIT License (MIT). Please see LICENSE for more information.