#!/usr/bin/env php
<?php
/***
 * Do not remove this file
 * This file allows running a localhost server 
 * by executing `php spark server-start` on the terminal 
 * 
 */
require_once __DIR__ . '/vendor/autoload.php';

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Command\Command;

class ServeCommand extends Command
{
    protected static $defaultName = 'start-server';

    protected function configure()
    {
        $this->setDescription('Start the SimplyPHP development server');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('<info>Starting SimplyPHP development server...</info>');
        $output->writeln('Server running at http://localhost:8000');
        passthru('php -S localhost:8000 -t ./');
        return Command::SUCCESS;
    }
}

$application = new Application();
$application->add(new ServeCommand());
$application->run();
