PHP code example of brotkrueml / twig-codehighlight

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

    

brotkrueml / twig-codehighlight example snippets


$twig->addExtension(new Brotkrueml\TwigCodeHighlight\Extension());

$twig->addExtension(new Brotkrueml\TwigCodeHighlight\Extension($myLogger));

$twig->addExtension(new Brotkrueml\TwigCodeHighlight\Extension(languageAliases: ['text' => 'plaintext', 'sh' => 'shell']));

$twig->addExtension(new Brotkrueml\TwigCodeHighlight\Extension(
    additionalLanguages: [
        ['custom_language', '/path/to/the/custom_language.json'],
        ['another_language', '/path/to/the/another_language.json', true],
    ]
));

    $twig->addExtension(new Brotkrueml\TwigCodeHighlight\Extension(classes: 'some-default-class'));
    
twig
{{ " echo 'test'; 
twig
{{ " echo 'test'; 
twig
{{ " echo 'test'; 
twig
{{ " echo 'test'; 
twig
{{ code | codehighlight(language="php", emphasizeLines="1-3,5") }}