public function register(Application $app, array $addons)
    {
        // prepare helper functions
        foreach ($addons as $addon) {
            $this->loadFiles($addon, $addon->config('addon.files', []));
        }

        foreach ($addons as $addon) {
            // load config
            $this->loadConfigurationFiles($addon);

            // regist service providers
            $providers = $addon->config('addon.providers', []);
            foreach ($providers as $provider) {
                $app->register($provider);
            }

            // register commands
            $commands = $addon->config('addon.commands', $addon->config('addon.console.commands', []));
            if (!is_array($commands)) $commands = [$commands];
            Artisan::starting(function ($artisan) use ($commands) {
                $artisan->resolveCommands($commands);
            });

            // register named middleware
            $middlewares = $addon->config('addon.middleware', $addon->config('addon.http.route_middlewares', []));
            foreach ($middlewares as $name => $middleware) {
                if (is_array($middleware)) {
                    $app['router']->middlewareGroup($name, $middleware);
                }
                else {
                    $app['router']->aliasMiddleware($name, $middleware);
                }
            }
        }
    }