Skip to content

Commit f9703fb

Browse files
committed
update some
1 parent 3054689 commit f9703fb

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

src/BuiltIn/DevServerCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,16 @@ public function execute($input, $output)
6767
$serveAddr .= ':' . $port;
6868
}
6969

70+
$docRoot = $input->getSameStringOpt('t,doc-root');
7071
$hceFile = $input->getStringOpt('hce-file');
7172
$hceEnv = $input->getStringOpt('hce-env');
72-
$docRoot = $input->getSameStringOpt('t,doc-root');
73+
$phpBin = $input->getStringOpt('php-bin');
7374

7475
$input->bindArgument('file', 0);
7576
$entryFile = $input->getStringArg('file');
7677

77-
$pds = PhpDevServe::new($serveAddr, $docRoot);
78-
$pds->setEntryFile($entryFile);
78+
$pds = PhpDevServe::new($serveAddr, $docRoot, $entryFile);
79+
$pds->setPhpBin($phpBin);
7980

8081
if ($hceEnv && $hceFile) {
8182
$pds->loadHceFile($hceFile);

src/Util/PhpDevServe.php

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class PhpDevServe
3030
*
3131
* @var string
3232
*/
33-
public $phpBin = self::PHP_BIN;
33+
protected $phpBin = self::PHP_BIN;
3434

3535
/**
3636
* The document root dir for server
3737
*
3838
* @var string
3939
*/
40-
public $docRoot = './';
40+
protected $docRoot = './';
4141

4242
/**
4343
* The entry file for server. e.g web/index.php
@@ -107,14 +107,14 @@ public static function findPhpBin(): string
107107
* Class constructor.
108108
*
109109
* @param string $serveAddr
110-
* @param string $documentRoot
110+
* @param string $docRoot
111111
* @param string $entryFile
112112
*/
113-
public function __construct(string $serveAddr, string $documentRoot, string $entryFile = '')
113+
public function __construct(string $serveAddr, string $docRoot, string $entryFile = '')
114114
{
115-
$this->docRoot = $documentRoot;
116-
$this->entryFile = $entryFile;
117115
$this->serveAddr = $serveAddr ?: self::SVR_ADDR;
116+
$this->setDocRoot($docRoot);
117+
$this->setEntryFile($entryFile);
118118
}
119119

120120
/**
@@ -323,4 +323,32 @@ public function setEntryFile(string $entryFile): self
323323
$this->entryFile = $entryFile;
324324
return $this;
325325
}
326+
327+
/**
328+
* @param string $phpBin
329+
*
330+
* @return PhpDevServe
331+
*/
332+
public function setPhpBin(string $phpBin): self
333+
{
334+
if ($phpBin) {
335+
$this->phpBin = $phpBin;
336+
}
337+
338+
return $this;
339+
}
340+
341+
/**
342+
* @param string $docRoot
343+
*
344+
* @return PhpDevServe
345+
*/
346+
public function setDocRoot(string $docRoot): self
347+
{
348+
if ($docRoot) {
349+
$this->docRoot = $docRoot;
350+
}
351+
352+
return $this;
353+
}
326354
}

0 commit comments

Comments
 (0)