Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Console] Add dumper #10502

Closed
ro0NL opened this issue Oct 17, 2018 · 0 comments
Closed

[Console] Add dumper #10502

ro0NL opened this issue Oct 17, 2018 · 0 comments
Labels
Console Waiting Code Merge Docs for features pending to be merged

Comments

@ro0NL
Copy link
Contributor

ro0NL commented Oct 17, 2018

see symfony/symfony#28898

@javiereguiluz javiereguiluz added Console Waiting Code Merge Docs for features pending to be merged labels Oct 18, 2018
fabpot added a commit to symfony/symfony that referenced this issue Mar 24, 2019
This PR was squashed before being merged into the 4.3-dev branch (closes #28898).

Discussion
----------

[Console] Add dumper

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#10502

This PR adds a new `Dumper` helper in the Console component. As there are 2 types of dumps

- debug purpose (e.g. `dd()`, `dump()`)
- output purpose (see #24208, #27684)

For the latter we cannot use the global system (debug) dumper, i.e. `VarDumper::dump()`, we need something tied to the current output and dependency free. Here it is:

```php
$io = new SymfonyStyle($input, $output);
$dumper = new Dumper($io);

$io->writeln($dumper([-0.5, 0, 1]));
$io->writeln($dumper(new \stdClass()));
$io->writeln($dumper(123));
$io->writeln($dumper('foo'));
$io->writeln($dumper(null));
$io->writeln($dumper(true));
```

With VarDumper comonent:

![image](https://user-images.githubusercontent.com/1047696/47069483-4cc26f80-d1ef-11e8-902e-2f9b0f040f25.png)

Without:

![image](https://user-images.githubusercontent.com/1047696/47069517-6663b700-d1ef-11e8-9328-ae1db0b83d7e.png)

> #27684 (comment) var-dumper is not a mandatory dep of fwb, can we do without?

Now we can  :)

Commits
-------

fc7465c [Console] Add dumper
@ro0NL ro0NL closed this as completed Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Console Waiting Code Merge Docs for features pending to be merged
Projects
None yet
Development

No branches or pull requests

2 participants