Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitbe1b55b

Browse files
committed
feature#26654 [VarDumper] Provide binary, allowing to start a server at any time (ogizanagi)
This PR was merged into the 4.1-dev branch.Discussion----------[VarDumper] Provide binary, allowing to start a server at any timeas soon as the "symfony/var-dumper" & "symfony/console" components are available.| Q | A| ------------- | ---| Branch? | master <!-- see below -->| Bug fix? | no| New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets | N/A <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | TODOsymfony/symfony-docs#9474Now that#23831 is merged, there is still room for improvements we can bring during the stabilization months.Here is a first one: providing a simple CLI binary allows to easily start a server from any project (or even globally), just by having the var dumper & console packages in your deps.Commits-------eef10b1 [VarDumper] Provide binary, allowing to start a server at any time
2 parents9dd89e0 +eef10b1 commitbe1b55b

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/*
5+
* This file is part of the Symfony package.
6+
*
7+
* (c) Fabien Potencier <fabien@symfony.com>
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
12+
13+
/**
14+
* Starts a dump server to collect and output dumps on a single place with multiple formats support.
15+
*
16+
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
17+
*/
18+
19+
usePsr\Log\LoggerInterface;
20+
useSymfony\Component\Console\Application;
21+
useSymfony\Component\Console\Input\ArgvInput;
22+
useSymfony\Component\Console\Input\InputOption;
23+
useSymfony\Component\Console\Logger\ConsoleLogger;
24+
useSymfony\Component\Console\Output\ConsoleOutput;
25+
useSymfony\Component\VarDumper\Command\ServerDumpCommand;
26+
useSymfony\Component\VarDumper\Server\DumpServer;
27+
28+
functionincludeIfExists(string$file):bool
29+
{
30+
returnfile_exists($file) &&include$file;
31+
}
32+
33+
if (
34+
!includeIfExists(__DIR__ .'/../../../../autoload.php') &&
35+
!includeIfExists(__DIR__ .'/../../vendor/autoload.php') &&
36+
!includeIfExists(__DIR__ .'/../../../../../../vendor/autoload.php')
37+
) {
38+
fwrite(STDERR,'Install dependencies using Composer.'.PHP_EOL);
39+
exit(1);
40+
}
41+
42+
if (!class_exists(Application::class)) {
43+
fwrite(STDERR,'You need the "symfony/console" component in order to run the VarDumper server.'.PHP_EOL);
44+
exit(1);
45+
}
46+
47+
$input =newArgvInput();
48+
$output =newConsoleOutput();
49+
$defaultHost ='127.0.0.1:9912';
50+
$host =$input->getParameterOption(['--host'],$_SERVER['VAR_DUMPER_SERVER'] ??$defaultHost,true);
51+
$logger =interface_exists(LoggerInterface::class) ?newConsoleLogger($output->getErrorOutput()) :null;
52+
53+
$app =newApplication();
54+
55+
$app->getDefinition()->addOption(
56+
newInputOption('--host',null, InputOption::VALUE_REQUIRED,'The address the server should listen to',$defaultHost)
57+
);
58+
59+
$app->add($command =newServerDumpCommand(newDumpServer($host,$logger)))
60+
->getApplication()
61+
->setDefaultCommand($command->getName(),true)
62+
->run($input,$output)
63+
;

‎src/Symfony/Component/VarDumper/composer.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"suggest": {
3333
"ext-iconv":"To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
3434
"ext-intl":"To show region name in time zone dump",
35-
"symfony/console":"To use the ServerDumpCommand"
35+
"symfony/console":"To use the ServerDumpCommand and/or the bin/var-dump-server script"
3636
},
3737
"autoload": {
3838
"files": ["Resources/functions/dump.php" ],
@@ -41,6 +41,9 @@
4141
"/Tests/"
4242
]
4343
},
44+
"bin": [
45+
"Resources/bin/var-dump-server"
46+
],
4447
"minimum-stability":"dev",
4548
"extra": {
4649
"branch-alias": {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp