1. Go to this page and download the library: Download ryangjchandler/phiki 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/ */
ryangjchandler / phiki example snippets
use Phiki\Phiki;
use Phiki\Grammar\Grammar;
use Phiki\Theme\Theme;
$phiki = new Phiki();
$html = $phiki->codeToHtml(
<<<'PHP'
echo "Hello, world!";
PHP,
Grammar::Php,
Theme::GithubDark,
);
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\MarkdownConverter;
use Phiki\CommonMark\PhikiExtension;
$environment = new Environment;
$environment
->addExtension(new CommonMarkCoreExtension)
->addExtension(new PhikiExtension('github-dark'));
$converter = new MarkdownConverter($environment);
$output = $converter->convert(<<<'MD'
use Phiki\CommonMark\PhikiExtension;
Str::markdown('...', extensions: [
new PhikiExtension('github-dark'),
]);
use Phiki\Environment\Environment;
$environment = Environment::default();
// Register a custom language.
$environment
->getGrammarRepository()
->register('my-language', __DIR__ . '/../path/to/grammar.json');
$environment
->getThemeRepository()
->register('my-theme', __DIR__ . '/../path/to/theme.json');
$phiki = new Phiki($environment);
$phiki->codeToHtml('...', 'my-language', 'my-theme');