public function index()
    {
        $argv = \Console_Getopt::readPHPArgv();
        $opts = \Console_Getopt::getopt(array_slice($argv, 2, count($argv) - 2), 'h::p::d::r::', null, true);
        if (!empty($opts[0]) && is_array($opts[0])) {
            foreach ($opts[0] as $val) {
                if (!empty($val[0]) && !empty($val[1]) && is_string($val[0]) && is_string($val[1])) {
                    switch ($val[0]) {
                        case 'h':
                            $this->host = $val[1];
                            break;
                        case 'p':
                            $this->port = $val[1];
                            break;
                        case 'd':
                            $this->docroot = $val[1];
                            break;
                        case 'r':
                            $this->router = $val[1];
                            break;
                    }
                }
            }
        }

        $documentRoot = $this->docroot;
        $address = $this->host . ':' . $this->port;
        if (!is_dir($documentRoot)) {
            Lb::app()->stop("Document root \"$documentRoot\" does not exist.\n", self::EXIT_CODE_NO_DOCUMENT_ROOT);
        }
        if ($this->isAddressTaken($address)) {
            Lb::app()->stop("http://$address is taken by another process.\n", self::EXIT_CODE_ADDRESS_TAKEN_BY_ANOTHER_PROCESS);
        }
        if ($this->router !== null && !file_exists($this->router)) {
            Lb::app()->stop("Routing file \"$this->router\" does not exist.\n", self::EXIT_CODE_NO_ROUTING_FILE);
        }
        $this->writeln("Server started on http://{$address}/\n");
        $this->writeln("Document root is \"{$documentRoot}\"\n");
        if ($this->router) {
            $this->writeln("Routing file is \"$this->router\"\n");
        }
        $this->writeln("Quit the server with CTRL-C or COMMAND-C.\n");
        passthru('"' . PHP_BINARY . '"' . " -S {$address} -t \"{$documentRoot}\" $this->router");
    }