PHP code example of brenno-duarte / modern-php-exception

1. Go to this page and download the library: Download brenno-duarte/modern-php-exception 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/ */

    

brenno-duarte / modern-php-exception example snippets


use ModernPHPException\ModernPHPException;

$exc = new ModernPHPException();
$exc->start();

$config = __DIR__ . '/config.example.yaml';

$exc = new ModernPHPException($config);
$exc->start();

$config = __DIR__ . '/config.example.yaml';

$exc = new ModernPHPException($config);
$exc->enableOccurrences(); // <- Before `start` method
$exc->start();



namespace Test;

use ModernPHPException\Solution;
use ModernPHPException\Interface\SolutionInterface;

class CustomException extends \Exception implements SolutionInterface
{
    public function getSolution(): Solution
    {
        return Solution::createSolution('My Solution')
            ->setDescription('description')
            ->setDocs('https://google.com');
    }

    #...

public static function staticCall()
{
    throw new CustomException("Error Processing Request");
}

get_debug_backtrace()

echo var_dump_buffer()

var_dump_debug()

/**
* @dumpignore-inheritance
* @dumpignore-inherited-class
* @dumpignore-private
* @dumpignore-public
* @dumpignore-public
*/
Class Foo extends Bar {
    /** @dumpignore */
    private ?BigObject $foo = null;
}

dump_die()

closure_dump()

use ModernPHPException\Debug;

Debug::log($message, $log_file);

use ModernPHPException\Debug;

Debug::log($message, $log_file, __FILE, __LINE__);

use ModernPHPException\Debug;

Debug::get($log_file);



odernPHPException\ModernPHPException;

$exc = new ModernPHPException();
$exc->start();

throw new Exception("Error Test", 1);

$a = new FakeClass();

composer 
yaml
enable_logs: false

# Default: sys_get_temp_dir() . "/ModernPHPExceptionLogs/ModernPHPExceptionLogs.log"
dir_logs: C:\wamp64\www\modern-php-exception\