Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
improved colors management and default configuration / added README
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyweb committed Jul 13, 2017
1 parent fc3afa9 commit fb3ebf2
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getConfigTreeBuilder()
->canBeDisabled()
->children()
->scalarNode('save_directory_path')->defaultValue('%kernel.root_dir%/../web/_html_cli_dumper_data')->cannotBeEmpty()->end()
->scalarNode('view_base_url')->defaultValue('%router.request_context.scheme%://%router.request_context.host%/_html_cli_dumper_data')->cannotBeEmpty()->end()
->scalarNode('view_base_url')->defaultValue('%router.request_context.scheme%://%router.request_context.host%%router.request_context.base_url%/_html_cli_dumper_data')->cannotBeEmpty()->end()
->booleanNode('disable_cli_dump')->defaultFalse()->end()
->end()
->end();
Expand Down
3 changes: 2 additions & 1 deletion Dumper/HtmlCliDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ public function dump(Data $data, $output = null)
$this->fs->dumpFile($this->saveDirectoryPath . $dumpFilename, stream_get_contents($output, -1, 0));
fclose($output);

$this->setColors(false);
$this->colors = false;
$this->line = sprintf("\n=== HTML dump url ===\n>>> %s\n", $this->viewBaseUrl . $dumpFilename);
parent::dumpLine(0);
$this->colors = null;

return $result;
}
Expand Down
76 changes: 75 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,75 @@
# html-cli-dumper-bundle
HtmlCliDumperBundle
===================

This bundle let you view your cli dumps as HTML dumps.

For every cli dump, it creates an HTML file containing the HTML version of the dump and display the link to this file in the console.

This is especially useful when you dump a large object in a `Command`, and you want to check a particular property that gets lost in thousand of lines.

Installation
------------

### Download the bundle
```bash
composer require fancyweb/html-cli-dumper-bundle --dev
```

### Register the bundle
```php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
// ...
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
// ...
if ('dev' === $this->getEnvironment()) {
// ...
$bundles[] = new Fancyweb\HtmlCliDumperBundle\HtmlCliDumperBundle();
}
}
}
// ...
}
```

### Requirement
This bundle only works when the Symfony `DebugBundle` is also registered.


Configuration
-------------

### Default
```yaml
html_cli_dumper:
enabled: true
save_directory_path: '%kernel.root_dir%/../web/_html_cli_dumper_data'
view_base_url: '%router.request_context.scheme%://%router.request_context.host%%router.request_context.base_url%/_html_cli_dumper_data'
disable_cli_dump: false
```

If you have properly configured your global request context with the dedicated parameters (cf https://symfony.com/doc/current/console/request_context.html), and if you use the default `web` directory, then you're good to go with the default configuration.

### Details

##### enabled
* Type : boolean
* Description : Enable the bundle ?

##### save_directory_path
* Type : string
* Description : The directory path where the HTML dumps are saved. If the directory doesn't exist, it will be created.

##### view_base_url
* Type : string
* Description : The base url that is prepended before the generated HTML dump unique id.

##### disable_cli_dump
* Type : boolean
* Description : Disable the cli dump output in the console ?

0 comments on commit fb3ebf2

Please sign in to comment.