PHP code example of farmaprom / translatable-exception

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

    

farmaprom / translatable-exception example snippets




use FarmaProm\TranslatableException\TranslatableException;

ction getTranslationKey()
    {
        return 'my_key';
    }

    public function getTranslationDomain()
    {
        return 'my_domain';
    }
}

try {

    throw (new MyException())->setTranslationParams(['param' => 'test']);
} catch (TranslatableException $e) {
    var_export($e);

    // Example usage with translator
//     $translator->trans($e->getTranslationKey(), $e->getTranslationParams(), $e->getTranslationDomain());
}