Last active
October 12, 2024 07:45
-
-
Save leek/10b7012151edda9f09e2c9d11b1245ff to your computer and use it in GitHub Desktop.
Laravel dd() for Magento 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function d($arg) { | |
if (is_object($arg)) { | |
echo PHP_EOL . 'CLASS: ' . get_class($arg) . PHP_EOL; | |
if ($arg instanceof \Magento\Framework\DB\Select) { | |
var_dump($arg->__toString()); | |
} | |
if (method_exists($arg, 'getSelect')) { | |
var_dump($arg->getSelect()->__toString()); | |
} | |
if (method_exists($arg, 'getItems')) { | |
foreach ($arg->getItems() as $_item) { | |
d($_item); | |
} | |
} | |
if (method_exists($arg, 'debug')) { | |
var_dump($arg->debug()); return; | |
} | |
if (method_exists($arg, 'getData')) { | |
var_dump($arg->getData()); return; | |
} | |
if (method_exists($arg, 'toArray')) { | |
var_dump($arg->toArray()); return; | |
} | |
} | |
// var_dump($arg); | |
} | |
function dd($arg) { | |
d($arg); exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment