Search by

echo-fusion / contracts

amir-shadanfar

Core interfaces and contracts for the EchoFusion framework, providing shared, standardized interfaces for cross-package interoperability and modular design.

Package info

github.com/echo-fusion/contracts

pkg:composer/echo-fusion/contracts

Statistics

Installs: 1 212

Dependents: 12

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.0 2026-10-12 12:12 UTC

README

CI Packagist PHP License

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.