Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ee32c98

Browse filesBrowse files
committed
Changes default pidfile location to project dir
1 parent 77f642e commit ee32c98
Copy full SHA for ee32c98

File tree

8 files changed

+46
-11
lines changed
Filter options

8 files changed

+46
-11
lines changed

‎src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
*/
3030
class ServerRunCommand extends Command
3131
{
32+
private $projectDir;
3233
private $documentRoot;
3334
private $environment;
3435

3536
protected static $defaultName = 'server:run';
3637

37-
public function __construct(string $documentRoot = null, string $environment = null)
38+
public function __construct(string $projectDir = null, string $documentRoot = null, string $environment = null)
3839
{
40+
$this->projectDir = $projectDir;
3941
$this->documentRoot = $documentRoot;
4042
$this->environment = $environment;
4143

@@ -129,7 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
129131
}
130132

131133
try {
132-
$server = new WebServer();
134+
$server = new WebServer($this->projectDir);
133135
$config = new WebServerConfig($documentRoot, $env, $input->getArgument('addressport'), $input->getOption('router'));
134136

135137
$message = sprintf('Server listening on http://%s', $config->getAddress());

‎src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
*/
3030
class ServerStartCommand extends Command
3131
{
32+
private $projectDir;
3233
private $documentRoot;
3334
private $environment;
3435

3536
protected static $defaultName = 'server:start';
3637

37-
public function __construct(string $documentRoot = null, string $environment = null)
38+
public function __construct(string $projectDir = null, string $documentRoot = null, string $environment = null)
3839
{
40+
$this->projectDir = $projectDir;
3941
$this->documentRoot = $documentRoot;
4042
$this->environment = $environment;
4143

@@ -133,7 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
133135
$this->getApplication()->setDispatcher(new EventDispatcher());
134136

135137
try {
136-
$server = new WebServer();
138+
$server = new WebServer($this->projectDir);
137139
if ($server->isRunning($input->getOption('pidfile'))) {
138140
$io->error(sprintf('The web server has already been started. It is currently listening on http://%s. Please stop the web server before you try to start it again.', $server->getAddress($input->getOption('pidfile'))));
139141

‎src/Symfony/Bundle/WebServerBundle/Command/ServerStatusCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebServerBundle/Command/ServerStatusCommand.php
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ class ServerStatusCommand extends Command
3030
{
3131
protected static $defaultName = 'server:status';
3232

33+
private $projectDir;
34+
35+
public function __construct(string $projectDir = null)
36+
{
37+
$this->projectDir = $projectDir;
38+
39+
parent::__construct();
40+
}
41+
3342
/**
3443
* {@inheritdoc}
3544
*/
@@ -64,7 +73,7 @@ protected function configure()
6473
protected function execute(InputInterface $input, OutputInterface $output)
6574
{
6675
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
67-
$server = new WebServer();
76+
$server = new WebServer($this->projectDir);
6877
if ($filter = $input->getOption('filter')) {
6978
if ($server->isRunning($input->getOption('pidfile'))) {
7079
list($host, $port) = explode(':', $address = $server->getAddress($input->getOption('pidfile')));

‎src/Symfony/Bundle/WebServerBundle/Command/ServerStopCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebServerBundle/Command/ServerStopCommand.php
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ class ServerStopCommand extends Command
2828
{
2929
protected static $defaultName = 'server:stop';
3030

31+
private $projectDir;
32+
33+
public function __construct(string $projectDir = null)
34+
{
35+
$this->projectDir = $projectDir;
36+
37+
parent::__construct();
38+
}
39+
3140
/**
3241
* {@inheritdoc}
3342
*/
@@ -55,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5564
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
5665

5766
try {
58-
$server = new WebServer();
67+
$server = new WebServer($this->projectDir);
5968
$server->stop($input->getOption('pidfile'));
6069
$io->success('Stopped the web server.');
6170
} catch (\Exception $e) {

‎src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebServerBundle/DependencyInjection/WebServerExtension.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function load(array $configs, ContainerBuilder $container)
2828
$loader->load('webserver.xml');
2929

3030
$publicDirectory = $this->getPublicDirectory($container);
31-
$container->getDefinition('web_server.command.server_run')->replaceArgument(0, $publicDirectory);
32-
$container->getDefinition('web_server.command.server_start')->replaceArgument(0, $publicDirectory);
31+
$container->getDefinition('web_server.command.server_run')->replaceArgument(1, $publicDirectory);
32+
$container->getDefinition('web_server.command.server_start')->replaceArgument(1, $publicDirectory);
3333

3434
if (!class_exists(ConsoleFormatter::class)) {
3535
$container->removeDefinition('web_server.command.server_log');

‎src/Symfony/Bundle/WebServerBundle/Resources/config/webserver.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebServerBundle/Resources/config/webserver.xml
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,26 @@
88
<defaults public="false" />
99

1010
<service id="web_server.command.server_run" class="Symfony\Bundle\WebServerBundle\Command\ServerRunCommand">
11+
<argument>%kernel.project_dir%</argument>
1112
<argument>%kernel.project_dir%/public</argument>
1213
<argument>%kernel.environment%</argument>
1314
<tag name="console.command" command="server:run" />
1415
</service>
1516

1617
<service id="web_server.command.server_start" class="Symfony\Bundle\WebServerBundle\Command\ServerStartCommand">
18+
<argument>%kernel.project_dir%</argument>
1719
<argument>%kernel.project_dir%/public</argument>
1820
<argument>%kernel.environment%</argument>
1921
<tag name="console.command" command="server:start" />
2022
</service>
2123

2224
<service id="web_server.command.server_stop" class="Symfony\Bundle\WebServerBundle\Command\ServerStopCommand">
25+
<argument>%kernel.project_dir%</argument>
2326
<tag name="console.command" command="server:stop" />
2427
</service>
2528

2629
<service id="web_server.command.server_status" class="Symfony\Bundle\WebServerBundle\Command\ServerStatusCommand">
30+
<argument>%kernel.project_dir%</argument>
2731
<tag name="console.command" command="server:status" />
2832
</service>
2933

‎src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/WebServerExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebServerBundle/Tests/DependencyInjection/WebServerExtensionTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public function testLoad()
2626

2727
$this->assertSame(
2828
__DIR__.'/test',
29-
$container->getDefinition('web_server.command.server_run')->getArgument(0)
29+
$container->getDefinition('web_server.command.server_run')->getArgument(1)
3030
);
3131
$this->assertSame(
3232
__DIR__.'/test',
33-
$container->getDefinition('web_server.command.server_start')->getArgument(0)
33+
$container->getDefinition('web_server.command.server_start')->getArgument(1)
3434
);
3535
$this->assertTrue($container->hasDefinition('web_server.command.server_run'));
3636
$this->assertTrue($container->hasDefinition('web_server.command.server_start'));

‎src/Symfony/Bundle/WebServerBundle/WebServer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebServerBundle/WebServer.php
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ class WebServer
2525
const STARTED = 0;
2626
const STOPPED = 1;
2727

28+
private $projectDir;
29+
30+
public function __construct(string $projectDir = null)
31+
{
32+
$this->projectDir = $projectDir;
33+
}
34+
2835
public function run(WebServerConfig $config, $disableOutput = true, callable $callback = null)
2936
{
3037
if ($this->isRunning()) {
@@ -166,6 +173,8 @@ private function createServerProcess(WebServerConfig $config)
166173

167174
private function getDefaultPidFile()
168175
{
169-
return getcwd().'/.web-server-pid';
176+
return $this->projectDir
177+
? $this->projectDir.'/.web-server-pid'
178+
: getcwd().'/.web-server-pid';
170179
}
171180
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.