authserver/homestead/src/UpCommand.php
author durandn
Tue, 13 Sep 2016 17:06:44 +0200
changeset 199 fe88e9c5dd60
parent 8 5a0cbbe0922a
permissions -rw-r--r--
Added tag 00.00.29 for changeset 2a51b81d594e

<?php namespace Laravel\Homestead;

use Symfony\Component\Process\Process;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class UpCommand extends Command {

	/**
	 * Configure the command options.
	 *
	 * @return void
	 */
	protected function configure()
	{
		$this->setName('up')
                  ->setDescription('Start the Homestead machine')
				  ->addOption('provision', null, InputOption::VALUE_NONE, 'Run the provisioners on the box.');
	}

	/**
	 * Execute the command.
	 *
	 * @param  \Symfony\Component\Console\Input\InputInterface  $input
	 * @param  \Symfony\Component\Console\Output\OutputInterface  $output
	 * @return void
	 */
	public function execute(InputInterface $input, OutputInterface $output)
	{
		$command = 'vagrant up';

		if ($input->getOption('provision'))
			$command .= ' --provision';

		$process = new Process($command, realpath(__DIR__.'/../'), array_merge($_SERVER, $_ENV), null, null);

		$process->run(function($type, $line) use ($output)
		{
			$output->write($line);
		});
	}

}