public function autoConfigureFromComposer(string $vendor_dir)
    {
        $main_dir = dirname($vendor_dir);

        // Add the main module
        $this->main_module = "main";
        $package = $main_dir . DIRECTORY_SEPARATOR . "composer.json";

        if (file_exists($package))
        {
            // A composer.json file should exist for a composer project,
            // so read the module name from that.
            $json = @file_get_contents($package);
            if ($json)
            {
                $js = @json_decode($json, true);
                if (isset($js['name']))
                    $this->main_module = $js['name'];
            }
        }

        // Register the main module with the highest precedence
        $this->registerModule($this->main_module, $main_dir, 0);

        $modules = $this->findModules($vendor_dir, "", 1);
        ksort($modules);

        $count = 0;
        foreach ($modules as $name => $path)
            $this->registerModule($name, $path, ++$count);

        return $this;
    }