-
-
Notifications
You must be signed in to change notification settings - Fork 188
/
ServerCommandController.php
54 lines (48 loc) · 1.71 KB
/
ServerCommandController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Neos\Flow\Command;
/*
* This file is part of the Neos.Flow package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;
use Neos\Flow\Core\Booting\Scripts;
/**
* Command controller for starting the development-server
*
* @Flow\Scope("singleton")
*/
class ServerCommandController extends CommandController
{
/**
* @Flow\InjectConfiguration
* @var array
*/
protected $settings;
/**
* Run a standalone development server
*
* Starts an embedded server, see http://php.net/manual/en/features.commandline.webserver.php
* Note: This requires PHP 5.4+
*
* To change the context Flow will run in, you can set the <b>FLOW_CONTEXT</b> environment variable:
* <i>export FLOW_CONTEXT=Development && ./flow server:run</i>
*
* @param string $host The host name or IP address for the server to listen on
* @param integer $port The server port to listen on
* @return void
*/
public function runCommand(string $host = '127.0.0.1', int $port = 8081)
{
$command = Scripts::buildPhpCommand($this->settings);
$address = sprintf('%s:%s', $host, $port);
$command .= ' -S ' . escapeshellarg($address) . ' -t ' . escapeshellarg(FLOW_PATH_WEB) . ' ' . escapeshellarg(FLOW_PATH_FLOW . '/Scripts/PhpDevelopmentServerRouter.php');
$this->outputLine('Server running. Please go to <b>http://' . $address . '</b> to browse the application.');
exec($command);
}
}