ghostff/php_prettify

Creates a syntax highlighted version of the given PHP code.

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 13

Watchers: 2

Forks: 2

Open Issues: 3

Language:HTML

pkg:composer/ghostff/php_prettify

dev-master 2021-12-04 02:44 UTC

This package is auto-updated.

Last update: 2025-10-04 11:40:26 UTC


README

Creates a syntax highlighted version of the given PHP code.

# PHP 8
composer require ghostff/php_prettify

# Older PHP version
composer require ghostff/php_prettify:5.4.093021
composer require ghostff/php_prettify:7.0.093021
<?php

use PhpPrettify\Highlight;

echo '<pre>', (new Highlight)->render('$name = "foobar"'), '</pre>';

Highlighting a file

<?php

use PhpPrettify\Highlight;

echo '<pre>', (new Highlight)
        ->setTheme('bittr')                             // Sets code highlight theme.
        ->setStyle('body {margin:0;padding:0}')         // Append css to default to style.
        ->setHighlight(22, ['style' => 'color:red'])    // Add html attributes to selected line(tr).
        ->showLineNumber(1, false)                      // Show line number starting from line 1 and prevent selection of line number.
        ->render('code.txt', true),
    '</pre>';

alt tag