src/ModuleBooter.php
protected function bootModule()
    {
        $base_namespace = self::$container["config"]->get("modules/base_namespace");
        $modules = self::$container["config"]->get("modules/modules");

        $controllers = [];

        foreach ($modules as $module)
        {
            $module_namespace = $base_namespace . "\\" . key($module);
            $module_class = $module_namespace . "\\Module";
            $module_object = new $module_class();

            if (! $module_object instanceof ModuleInterface) {
                throw new \InvalidArgumentException(
                    "Module {$module_class} must be instance of ServiceProviderInterface"
                );
            }

            /**
             * register service provider and command handler
             */
            $this
                ->bootModuleServiceProvider($module_object)
                ->bootModuleCommand($module_object)
                ->bootModuleCli($module_object);

            /**
             * replace controller with full namespace
             */
            if (isset($module[key($module)]["controllers"])) {
                $routes = $module[key($module)]["controllers"];
                array_walk($routes, function (&$item) use ($module_namespace) {
                    $item = $module_namespace . "\\Controllers\\" . $item;
                });

                $controllers = array_merge($controllers, $routes);
            }
        }

        /**
         * register annotation controller
         */
        self::$container->register(
            new AnnotationRouting(),
            [
                "annot.cache" => (isset(self::$container["cache.factory"])) ? self::$container["cache.factory"] : null,
                "annot.controllers" => $controllers
            ]
        );
    }
protected function bootModule()
    {
        $base_namespace = self::$container["config"]->get("modules/base_namespace");
        $modules = self::$container["config"]->get("modules/modules");

        $controllers = [];

        foreach ($modules as $module)
        {
            $module_namespace = $base_namespace . "\\" . key($module);
            $module_class = $module_namespace . "\\Module";
            $module_object = new $module_class();

            if (! $module_object instanceof ModuleInterface) {
                throw new \InvalidArgumentException(
                    "Module {$module_class} must be instance of ServiceProviderInterface"
                );
            }

            /**
             * register service provider and command handler
             */
            $this
                ->bootModuleServiceProvider($module_object)
                ->bootModuleCommand($module_object)
                ->bootModuleCli($module_object);

            /**
             * replace controller with full namespace
             */
            if (isset($module[key($module)]["controllers"])) {
                $routes = $module[key($module)]["controllers"];
                array_walk($routes, function (&$item) use ($module_namespace) {
                    $item = $module_namespace . "\\Controllers\\" . $item;
                });

                $controllers = array_merge($controllers, $routes);
            }
        }

        /**
         * register annotation controller
         */
        self::$container->register(
            new AnnotationRouting(),
            [
                "annot.cache" => (isset(self::$container["cache.factory"])) ? self::$container["cache.factory"] : null,
                "annot.controllers" => $controllers
            ]
        );
    }
boot module