PHP code example of dominicwatts / magentodump

1. Go to this page and download the library: Download dominicwatts/magentodump 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/ */

    

dominicwatts / magentodump example snippets


use Symfony\Component\VarDumper\VarDumper;

/**
 * Class Dump
 * @package Xigen\MagentoDump\Block\Index
 */
class Dump extends \Magento\Framework\View\Element\Template
{
    /**
     * Constructor
     * @param \Magento\Framework\View\Element\Template\Context $context
     * @param array $data
     */
    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
        array $data = []
    ) {
        parent::__construct($context, $data);
    }

    /**
     * Dump the variable
     * @param $dumpMe mixed
     */
    public function dump($dumpMe)
    {
        VarDumper::dump($dumpMe);
    }
}
phtml
<p>Hello index/dump.phtml</p>


Symfony\Component\VarDumper\VarDumper::dump('test');

$block->dump('test');

$block->dump(['arrayone', 'arraytwo']);

$object = ['key' => 'item'];

$block->dump(['array', 1, new Magento\Framework\DataObject($object)]);