Index
# Modules Modules are special Singleton classes (they only have one instance). They are a group of functions that shares common data. ## Get Started - A module implements <@\MMO\core\interfaces\iModule>. - You can get an instance of a module using the static method `::Shared()`. - Any method can be called statically. Internaly it will first call `Shared()` and then the method. - You can access its configuration using the method `config()`. ## Implementing a module Let's declare a module with a simple configuration: ```php class MyModule extends aModule { //built from config, `date` goes through setDate() instead of a plain assignment #[\MMO\core\attributes\Serialize(unserialize: 'setDate')] protected \DateTimeInterface $date; public function setDate(string|\DateTimeInterface $date): void { $this->date = is_string($date)? new \DateTimeImmutable($date) : $date; } } ``` ## References ### See also ## Tags <#event>, <#signal>