PHP code example of pointybeard / helpers-functions-debug

1. Go to this page and download the library: Download pointybeard/helpers-functions-debug 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/ */

    

pointybeard / helpers-functions-debug example snippets




declare(strict_types=1);

ns\Debug;

echo Debug\readable_debug_backtrace().PHP_EOL;
// [./test.php:7] pointybeard\Helpers\Functions\Debug\readable_debug_backtrace();
//
echo Debug\readable_debug_backtrace(null, '{{FUNCTION}}() in {{FILENAME}} on line {{LINE}}').PHP_EOL;
// pointybeard\Helpers\Functions\Debug\readable_debug_backtrace() in test.php on line 10

$sampleTrace = [
    [
        'file' => 'Console/AbstractCommand.php',
        'line' => '38',
        'function' => 'init',
        'class' => 'AbstractCommand',
        'type' => '->',
    ],
    [
        'file' => 'console/commands/Symphony.php',
        'line' => '18',
        'function' => '__construct',
        'class' => 'AbstractCommand',
        'type' => '->',
    ],
    [
        'file' => 'vendor/pointybeard/helpers-foundation-factory/src/Factory/AbstractFactory.php',
        'line' => '57',
        'function' => '__construct',
        'class' => "Commands\Console\Symphony",
        'type' => '->',
    ],
    [
        'file' => 'Console/CommandFactory.php',
        'line' => '47',
        'function' => 'instanciate',
        'class' => "Factory\AbstractFactory",
        'type' => '::',
    ],
    [
        'file' => 'console/bin/symphony',
        'line' => '54',
        'function' => 'build',
        'class' => 'CommandFactory',
        'type' => '::',
    ],
];

echo Debug\readable_debug_backtrace($sampleTrace, '{{CLASS}}{{TYPE}}{{FUNCTION}}() in {{FILENAME}} on line {{LINE}}').PHP_EOL;
// AbstractCommand->init() in AbstractCommand.php on line 38
// AbstractCommand->__construct() in Symphony.php on line 18
// Commands\Console\Symphony->__construct() in AbstractFactory.php on line 57
// Factory\AbstractFactory::instanciate() in CommandFactory.php on line 47
// CommandFactory::build() in symphony on line 54

Debug\dd(
    'apple',
    1,
    false,
    []
);
// string(5) "apple"
// int(1)
// bool(false)
// array(0) {}