2 namespace Robo\Task\Development;
4 use Robo\Task\Base\Exec;
7 * Runs PHP server and stops it when task finishes.
11 * // run server in /public directory
12 * $this->taskServer(8000)
16 * // run with IP 0.0.0.0
17 * $this->taskServer(8000)
21 * // execute server in background
22 * $this->taskServer(8000)
28 class PhpServer extends Exec
38 protected $host = '127.0.0.1';
43 protected $command = 'php -S %s:%d ';
48 public function __construct($port)
52 if (strtolower(PHP_OS) === 'linux') {
53 $this->command = 'exec php -S %s:%d ';
62 public function host($host)
73 public function dir($path)
75 $this->command .= "-t $path";
82 public function getCommand()
84 return sprintf($this->command . $this->arguments, $this->host, $this->port);