var_dump()
function var_dump()
more modern and functional alternative - the dump()
function.DebugBundle
connected in AppKernel
: // app/AppKernel.php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... ); if (in_array($this->getEnvironment(), array('dev', 'test'))) { $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); // ... } } // ... }
var_dump()
function with a new and shorter dump()
. Unlike var_dump()
, you can safely use dump()
to display the contents of any variables, including variables with circular references, such as Doctrine entities.Request
object: namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class DefaultController extends Controller { public function indexAction(Request $request) { dump($this->container, $request); // ... } }
dump
panel that records all the requested variables and briefly shows their contents:exit
or die()
in your code. In these cases, the variables are written to the standard output.{% dump %}
tag and the {{ dump() }}
function for checking variables directly from Twig templates. The {% dump %}
tag shows variables in the debug panel (for example, {% dump variable1, variable2 %}
). A great option when the output of the template should not be changed.{{ dump() }}
function, on the contrary, displays the contents of variables directly in the template (for example, {{ dump(variable1, variable2) }}
).debug-bundle
as follows: $ composer require --dev tchwork/debug-bundle
Source: https://habr.com/ru/post/245623/
All Articles