PHP code example of szczyglis / extended-dump-bundle
1. Go to this page and download the library: Download szczyglis/extended-dump-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// src/Controller/IndexController.php
namespace App\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
/**
* Class IndexController
* @package App\Controller
*/
class IndexController extends AbstractController
{
/**
* @Route("/", name="index")
* @param Request $request
* @return Response
*/
public function index(Request $request)
{
$foo1 = 'bar1';
$foo2 = 'bar2';
xdump($foo1, $foo2); // you can put one or multiple arguments
return $this->render('index.html.twig');
}
}
// src/EventSubscriber/CustomDumpSubscriber.php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Szczyglis\ExtendedDumpBundle\Event\ExtendedDumpEvents;
use Szczyglis\ExtendedDumpBundle\Event\RenderEvent;
class CustomDumpSubscriber implements EventSubscriberInterface
{
/**
* @param RenderEvent $event
*/
public function onRender(RenderEvent $event)
{
$foo = "I want to be dumped every time!";
$event->add($foo, "I'm Event object");
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
ExtendedDumpEvents::RENDER => 'onRender',
];
}
}
class CustomDumpSubscriber implements EventSubscriberInterface
{
/**
* @param RenderEvent $event
*/
public function onRender(RenderEvent $event)
{
$foo1 = "bar1";
$foo2 = "bar2";
$event->add($foo1, "Optional label to display");
$event->add($foo2);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.