Skip to content

Instantly share code, notes, and snippets.

@nicolas-grekas
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolas-grekas/9131243 to your computer and use it in GitHub Desktop.
Save nicolas-grekas/9131243 to your computer and use it in GitHub Desktop.
dumper-test.php
<?php
// composer require patchwork/dumper '1.0.*'
require __DIR__ . '/vendor/autoload.php';
set_debug_handler(function ($var) {
$c = new Patchwork\Dumper\Collector\PhpCollector();
$data = $c->collect($var);
$data->dump(new Patchwork\Dumper\CliDumper());
});
$var = 1.0;
dump($var);
$var = fopen(__FILE__, 'rb');
dump($var);
class foo
{
public $pub = 'Pub';
protected $prot = 'Prot';
private $priv = 'Priv';
}
$foo = new foo;
$var = array($foo, $foo);
dump($var);
$var = array($foo);
$var[1] =& $var[0];
$foo->pub = $var;
dump($var);
$var = new SplQueue;
$var->enqueue(123);
dump($var);
diff --git a/app/AppKernel.php b/app/AppKernel.php
index c5c9eb6..58294e7 100644
--- a/app/AppKernel.php
+++ b/app/AppKernel.php
@@ -23,6 +23,7 @@ class AppKernel extends Kernel
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
+ $bundles[] = new Patchwork\DumperBundle\PatchworkDumperBundle();
}
return $bundles;
diff --git a/composer.json b/composer.json
index dad465b..e15e704 100644
--- a/composer.json
+++ b/composer.json
@@ -8,6 +8,7 @@
},
"require": {
"php": ">=5.3.3",
+ "patchwork/dumper": "1.0.*",
"symfony/symfony": "~2.4",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
diff --git a/src/Acme/DemoBundle/Controller/DemoController.php b/src/Acme/DemoBundle/Controller/DemoController.php
index a99de89..fbddc5f 100644
--- a/src/Acme/DemoBundle/Controller/DemoController.php
+++ b/src/Acme/DemoBundle/Controller/DemoController.php
@@ -28,6 +28,8 @@ class DemoController extends Controller
*/
public function helloAction($name)
{
+ debug($this);
+
return array('name' => $name);
}
diff --git a/src/Acme/DemoBundle/Resources/views/Demo/hello.html.twig b/src/Acme/DemoBundle/Resources/views/Demo/hello.html.twig
index 3997ff6..b5b7689 100644
--- a/src/Acme/DemoBundle/Resources/views/Demo/hello.html.twig
+++ b/src/Acme/DemoBundle/Resources/views/Demo/hello.html.twig
@@ -4,6 +4,9 @@
{% block content %}
<h1>Hello {{ name }}!</h1>
+
+{{ debug() }}
+
{% endblock %}
{% set code = code(_self) %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment