ModuleInterface#

Georgeff\Kernel\Module\ModuleInterface

The base contract for all modules. Every module must implement register(). See also ConfigurableModuleInterface and BootableModuleInterface for extended contracts.

Methods#

public function register(KernelInterface $kernel): void;

Called during the moduleRegistration boot phase. Use this method to register services, tags, decorators, and any other kernel configuration.

Example#

use Georgeff\Kernel\KernelInterface;
use Georgeff\Kernel\Module\ModuleInterface;

final class CacheModule implements ModuleInterface
{
    public function register(KernelInterface $kernel): void
    {
        $kernel->define(CacheInterface::class, fn() => new RedisCache())
            ->share();

        $kernel->define(CacheWarmer::class, fn($c) => new CacheWarmer(
            $c->get(CacheInterface::class)
        ));
    }
}